|
VLink 2.0.0
A high-performance communication middleware
|
Background MessageLoop that aggregates live VLink endpoint discovery data.
更多...
#include <discovery_viewer.h>
类 | |
| struct | Process |
| Information about one process that hosts a VLink endpoint. 更多... | |
| struct | Info |
| Aggregated discovery entry for one VLink URL. 更多... | |
Public 类型 | |
| enum | FilterType : uint8_t { kFilterNone = 0 , kFilterAvailable = 1 , kFilterNative = 2 } |
| Controls which endpoints are included in the discovery view. 更多... | |
| using | Callback = std::function<void(const std::vector<Info>& info_list)> |
| Callback fired whenever the discovery information is updated. | |
| Public 类型 继承自 vlink::MessageLoop | |
| enum | Type : uint8_t { kNormalType = 0 , kLockfreeType = 1 , kPriorityType = 2 } |
| Queue implementation type. 更多... | |
| enum | Strategy : uint8_t { kOptimizationStrategy = 0 , kPopStrategy = 1 , kBlockStrategy = 2 } |
| Idle strategy controlling CPU and latency trade-offs. 更多... | |
| enum | Priority : uint16_t { kNoPriority = 0 , kLowestPriority = 1 , kTimerPriority = 50 , kNormalPriority = 100 , kHighestPriority = std::numeric_limits<uint16_t>::max() } |
Pre-defined task priority levels for kPriorityType loops. 更多... | |
| using | Callback = std::function<void()> |
| Callback type for tasks and event handlers. | |
Public 成员函数 | |
| DiscoveryViewer (FilterType type=kFilterNone) | |
Constructs a DiscoveryViewer with the given filter type. | |
| ~DiscoveryViewer () override | |
| Destructor – stops the viewer loop. | |
| void | register_callback (Callback &&callback) |
| Registers the callback invoked when the endpoint list changes. | |
| std::vector< Info > | get_info_list () |
| Returns a snapshot of the current discovery information. | |
| std::string | get_ser_type (const std::string &url) const |
| Returns the serialisation type string for a given URL. | |
| SchemaType | get_schema_type (const std::string &url) const |
| Returns the coarse schema family for a given URL. | |
| Public 成员函数 继承自 vlink::MessageLoop | |
| MessageLoop () | |
Constructs a MessageLoop with kNormalType queue. | |
| MessageLoop (Type type) | |
Constructs a MessageLoop with the specified queue type. | |
| virtual | ~MessageLoop () |
Destructor. Calls quit(true) and waits for the background thread (if any). | |
| void | set_name (const std::string &name) |
| Sets a human-readable name for this loop (visible in profiling tools). | |
| const std::string & | get_name () const |
Returns the name set via set_name(). | |
| Type | get_type () const |
| Returns the queue type this loop was constructed with. | |
| Strategy | get_strategy () const |
| Returns the current idle dispatch strategy. | |
| void | set_strategy (Strategy strategy) |
| Changes the idle dispatch strategy. | |
| void | register_begin_handler (Callback &&callback) |
| Registers a callback invoked once when the loop thread starts. | |
| void | register_end_handler (Callback &&callback) |
| Registers a callback invoked once when the loop thread exits. | |
| void | register_idle_handler (Callback &&callback) |
| Registers a callback invoked each time the task queue becomes empty. | |
| bool | run () |
| Runs the message loop on the calling thread (blocking). | |
| bool | async_run () |
| Starts the message loop on a new background thread (non-blocking). | |
| bool | spin () |
| Runs the loop continuously in a spin mode (blocking; no background thread). | |
| bool | spin_once (bool block=true) |
| Processes one batch of pending tasks and timers. | |
| bool | quit (bool force=false) |
| Requests the loop to exit cleanly. | |
| bool | wait_for_idle (int ms=Timer::kInfinite, bool check=true) |
| Waits until the task queue is drained. | |
| bool | wait_for_quit (int ms=Timer::kInfinite, bool check=true) |
Waits until the loop has fully exited (after quit() was called). | |
| bool | post_task (Callback &&callback) |
| Posts a task to the queue for execution on the loop thread. | |
| bool | post_task_with_priority (Callback &&callback, uint16_t priority) |
Posts a task with an explicit priority (requires kPriorityType loop). | |
| 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) |
Posts a scheduled task and returns a Schedule::Status for chaining callbacks. | |
| 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) |
Posts a scheduled task and returns a Schedule::RetStatus for chaining callbacks. | |
| bool | wakeup () |
Wakes the loop thread if it is sleeping (e.g., in kBlockStrategy). | |
| void | reset_lockfree_capacity () |
| Resets the lock-free queue to its initial capacity. | |
| bool | is_running () const |
Returns true if the loop is currently running (started and not quit). | |
| bool | is_ready_to_quit () const |
Returns true if quit() has been called and the loop is winding down. | |
| bool | is_busy () const |
Returns true if the loop is currently executing a task. | |
| size_t | get_task_count () const |
| Returns the number of tasks currently in the queue. | |
| virtual size_t | get_max_timer_count () const |
| Returns the maximum number of timers that can be attached to this loop. | |
| virtual bool | is_in_same_thread () const |
Returns true if the calling thread is the same as the loop thread. | |
| 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. | |
| 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) |
Dispatches a callable with an explicit priority and returns a std::future. | |
静态 Public 成员函数 | |
| static ImplType | convert_type (std::string_view str) |
Converts a transport string to the corresponding ImplType value. | |
| static std::string | convert_type_to_view (uint32_t type) |
Returns a display string for an ImplType bitmask. | |
| static std::string | convert_type_to_view (uint32_t type, const std::vector< Process > &process_list) |
| Returns a combined type-and-process display string. | |
| static std::string | get_listen_address () |
| Returns the intra-process address used by the discovery subsystem. | |
| static DiscoveryViewer * | global_get () |
Returns the process-global DiscoveryViewer singleton. | |
Protected 成员函数 | |
| size_t | get_max_task_count () const override |
| Returns the maximum queue depth. | |
| uint32_t | get_max_elapsed_time () const override |
| Returns the maximum allowed task execution time in milliseconds. | |
| void | on_begin () override |
| Called from the loop thread just before the first task is processed. | |
| void | on_end () override |
| Called from the loop thread just after the last task has been processed. | |
| Protected 成员函数 继承自 vlink::MessageLoop | |
| virtual void | on_idle () |
| Called from the loop thread each time the queue becomes empty. | |
| virtual void | on_task_changed (Callback &&callback, uint32_t start_time) |
| Called before each task is executed. | |
| virtual void | on_task_timeout (Callback &&callback, uint32_t elapsed_time) |
Called when a task's execution time exceeds get_max_elapsed_time(). | |
Background MessageLoop that aggregates live VLink endpoint discovery data.
| using vlink::DiscoveryViewer::Callback = std::function<void(const std::vector<Info>& info_list)> |
Callback fired whenever the discovery information is updated.
Invoked on the viewer's event loop thread. The vector is a snapshot of the current live endpoint list.
| enum vlink::DiscoveryViewer::FilterType : uint8_t |
Controls which endpoints are included in the discovery view.
| Value | Meaning |
|---|---|
| kFilterNone | All discovered endpoints |
| kFilterAvailable | Endpoints with at least one live process |
| kFilterNative | Endpoints from the local host only |
| 枚举值 | |
|---|---|
| kFilterNone | Show all endpoints. |
| kFilterAvailable | Show only endpoints with live processes. |
| kFilterNative | Show only local-host endpoints. |
|
explicit |
Constructs a DiscoveryViewer with the given filter type.
| type | Controls which endpoints are included. Default: kFilterNone. |
|
override |
Destructor – stops the viewer loop.
|
staticnodiscard |
|
staticnodiscard |
|
staticnodiscard |
Returns a combined type-and-process display string.
| type | ImplType bitmask. |
| process_list | List of processes to include in the display. |
|
nodiscard |
Returns a snapshot of the current discovery information.
Info list at the time of the call.
|
staticnodiscard |
Returns the intra-process address used by the discovery subsystem.
|
overrideprotectedvirtual |
Returns the maximum allowed task execution time in milliseconds.
When a task exceeds this duration, on_task_timeout() is called. Returns 0 to disable timeout checking.
重载 vlink::MessageLoop .
|
overrideprotectedvirtual |
|
nodiscard |
Returns the coarse schema family for a given URL.
| url | Topic URL to look up. |
SchemaType::kUnknown if not known.
|
nodiscard |
Returns the serialisation type string for a given URL.
| url | Topic URL to look up. |
"demo.proto.PointCloud"), or empty if not known.
|
static |
Returns the process-global DiscoveryViewer singleton.
Created with kFilterNone on first call. The singleton is destroyed on process exit.
DiscoveryViewer.
|
overrideprotectedvirtual |
Called from the loop thread just before the first task is processed.
Override in subclasses to perform per-thread initialisation.
重载 vlink::MessageLoop .
|
overrideprotectedvirtual |
Called from the loop thread just after the last task has been processed.
Override in subclasses to perform per-thread cleanup.
重载 vlink::MessageLoop .
| void vlink::DiscoveryViewer::register_callback | ( | Callback && | callback | ) |
Registers the callback invoked when the endpoint list changes.
Replaces any previously registered callback. The callback is invoked on the viewer's loop thread.
| callback | Function receiving the updated Info list. |