|
VLink
2.0.0
A high-performance communication middleware
|
Periodic multicast broadcaster of the process's active VLink endpoints. More...
#include <discovery_reporter.h>
Public Member Functions | |
| DiscoveryReporter () | |
| Builds the reporter, opens its UDP socket and arms the periodic timer. More... | |
| ~DiscoveryReporter () override | |
| Stops the loop and releases the UDP socket. More... | |
| void | add (NodeImpl *node) |
| Registers a node so that subsequent broadcasts include it. More... | |
| void | remove (NodeImpl *node) |
| Unregisters a node so that subsequent broadcasts exclude it. More... | |
Public Member Functions inherited from vlink::MessageLoop | |
| MessageLoop () | |
Constructs a loop with the default kNormalType queue. More... | |
| MessageLoop (Type type) | |
| Constructs a loop with the given queue type. More... | |
| virtual | ~MessageLoop () |
| Destructor; requests quit and joins the dispatcher thread if needed. More... | |
| void | set_name (const std::string &name) |
| Sets a human-readable name visible to profiling tools. More... | |
| const std::string & | get_name () const |
Returns the loop name set via set_name. More... | |
| Type | get_type () const |
| Returns the queue type this loop was constructed with. More... | |
| Strategy | get_strategy () const |
| Returns the active back-pressure strategy. More... | |
| void | set_strategy (Strategy strategy) |
| Replaces the back-pressure strategy. More... | |
| void | register_begin_handler (Callback &&callback) |
| Registers a callback fired once at loop thread startup. More... | |
| void | register_end_handler (Callback &&callback) |
| Registers a callback fired once when the loop thread exits. More... | |
| void | register_idle_handler (Callback &&callback) |
| Registers a callback fired every time the queue becomes empty. More... | |
| bool | run () |
Runs the loop on the calling thread until quit is requested. More... | |
| bool | async_run () |
| Starts the loop on a new background thread. More... | |
| bool | spin () |
Alias of run blocking the calling thread. More... | |
| bool | spin_once (bool block=true) |
| Processes one batch of pending tasks and timers on the calling thread. More... | |
| bool | quit (bool force=false) |
| Requests the loop to exit. More... | |
| bool | wait_for_quit (int ms=Timer::kInfinite, bool check=true) |
| Waits until the loop has fully exited. More... | |
| bool | post_task (Callback &&callback) |
| Posts a task for execution on the loop thread. More... | |
| TaskHandle | post_task_handle (Callback &&callback, const PostTaskOptions &options={}) |
Tracked variant of post_task returning a TaskHandle. More... | |
| bool | post_task_with_priority (Callback &&callback, uint16_t priority) |
Posts a task with an explicit priority on a kPriorityType loop. More... | |
| TaskHandle | post_task_with_priority_handle (Callback &&callback, uint16_t priority, const PostTaskOptions &options={}) |
Tracked variant of post_task_with_priority returning a TaskHandle. More... | |
| template<typename CallbackT , typename = std::enable_if_t<!std::is_convertible_v<CallbackT, Schedule::RetCallback>>> | |
| Schedule::Status | exec_task (const Schedule::Config &config, CallbackT &&callback) |
Schedules a void-returning callable and returns a chainable Schedule::Status. More... | |
| template<typename CallbackT , typename = std::enable_if_t<std::is_convertible_v<CallbackT, Schedule::RetCallback>>> | |
| Schedule::RetStatus | exec_task (const Schedule::Config &config, CallbackT &&callback) |
Schedules a bool-returning callable and returns a chainable Schedule::RetStatus. More... | |
| bool | wakeup () |
| Wakes the loop thread if it is suspended in its idle wait. More... | |
| void | reset_lockfree_capacity () |
| Recreates the lock-free queue, clearing all queued tasks and counters. More... | |
| bool | is_running () const |
| Reports whether the loop is currently running. More... | |
| bool | is_ready_to_quit () const |
Reports whether quit has been requested and the loop is winding down. More... | |
| bool | is_busy () const |
| Reports whether the loop is currently executing a task. More... | |
| size_t | get_task_count () const |
| Returns the current pending task count. More... | |
| virtual bool | wait_for_idle (int ms=Timer::kInfinite, bool check=true) |
| Waits until the loop has drained its queue and is not executing a task. More... | |
| virtual size_t | get_max_timer_count () const |
| Returns the maximum number of timers that can be attached. More... | |
| virtual bool | is_in_same_thread () const |
| Reports whether the calling thread is owned by this loop. More... | |
| std::shared_ptr< AliveState > | get_alive_state () const |
| Returns the shared lifetime flag used by cross-thread bridges. More... | |
| template<class FunctionT , class... ArgsT, typename ResultT = std::invoke_result_t<FunctionT, ArgsT...>> | |
| std::future< ResultT > | invoke_task (FunctionT &&function, ArgsT &&... args) |
Dispatches a callable to the loop thread and returns a std::future for the result. More... | |
| template<class FunctionT , class... ArgsT, typename ResultT = std::invoke_result_t<FunctionT, ArgsT...>> | |
| std::future< ResultT > | invoke_task_with_priority (FunctionT &&function, uint16_t priority, ArgsT &&... args) |
Priority variant of invoke_task; requires a kPriorityType loop. More... | |
Protected Member Functions | |
| size_t | get_max_task_count () const override |
| Returns the maximum queue depth. More... | |
| uint32_t | get_max_elapsed_time () const override |
| Returns the maximum allowed task execution time in milliseconds. More... | |
| void | on_begin () override |
| Hook invoked once on the loop thread before the first task runs. More... | |
| void | on_end () override |
| Hook invoked once on the loop thread after the last task runs. More... | |
Protected Member Functions inherited from vlink::MessageLoop | |
| virtual void | on_idle () |
| Hook invoked on the loop thread each time the queue becomes empty. More... | |
| virtual void | on_task_changed (Callback &&callback, uint32_t start_time) |
| Dispatches a ready task on the loop thread. More... | |
| virtual void | on_task_timeout (Callback &&callback, uint32_t elapsed_time) |
Hook invoked when a task exceeds get_max_elapsed_time(). More... | |
Additional Inherited Members | |
Public Types inherited from vlink::MessageLoop | |
| enum | Type : uint8_t { kNormalType = 0 , kLockfreeType = 1 , kPriorityType = 2 } |
| Internal queue implementation type. More... | |
| enum | Strategy : uint8_t { kOptimizationStrategy = 0 , kPopStrategy = 1 , kBlockStrategy = 2 } |
| Back-pressure strategy applied when the bounded queue is at capacity. More... | |
| enum | Priority : uint16_t { kNoPriority = 0 , kLowestPriority = 1 , kTimerPriority = 50 , kNormalPriority = 100 , kHighestPriority = std::numeric_limits<uint16_t>::max() } |
Built-in priority levels for kPriorityType loops; higher values dispatch first. More... | |
| using | Callback = MoveFunction< void()> |
| Callback type for tasks and event handlers. More... | |
Periodic multicast broadcaster of the process's active VLink endpoints.
| vlink::DiscoveryReporter::DiscoveryReporter | ( | ) |
Builds the reporter, opens its UDP socket and arms the periodic timer.
The MessageLoop is left idle; callers are responsible for calling async_run(). The runtime-owned process reporter does this automatically.
|
override |
Stops the loop and releases the UDP socket.
An offline notification is only emitted when offline reporting is compiled in; the default build omits it.
| void vlink::DiscoveryReporter::add | ( | NodeImpl * | node | ) |
Registers a node so that subsequent broadcasts include it.
Invoked automatically by NodeImpl::init_ext().
| node | Node endpoint to track. |
|
overrideprotectedvirtual |
Returns the maximum allowed task execution time in milliseconds.
Tasks exceeding this duration trigger on_task_timeout. Zero disables the check.
Reimplemented from vlink::MessageLoop.
|
overrideprotectedvirtual |
Returns the maximum queue depth.
kMaxTaskSize (10000) by default. Reimplemented from vlink::MessageLoop.
|
overrideprotectedvirtual |
Hook invoked once on the loop thread before the first task runs.
Subclasses override to perform per-thread initialisation.
Reimplemented from vlink::MessageLoop.
|
overrideprotectedvirtual |
Hook invoked once on the loop thread after the last task runs.
Subclasses override to perform per-thread cleanup.
Reimplemented from vlink::MessageLoop.
| void vlink::DiscoveryReporter::remove | ( | NodeImpl * | node | ) |
Unregisters a node so that subsequent broadcasts exclude it.
Invoked automatically by NodeImpl::deinit_ext().
| node | Node endpoint to drop. |