|
VLink
2.0.0
A high-performance communication middleware
|
In-process VLink proxy daemon backed by a MessageLoop.
更多...
#include <proxy_server.h>
类 | |
| struct | Config |
Construction-time configuration aggregate for ProxyServer. 更多... | |
Public 成员函数 | |
| ProxyServer (const Config &config) | |
Constructs a ProxyServer and brings every proxy subsystem online. 更多... | |
| ~ProxyServer () override | |
Destroys the ProxyServer in a deterministic shutdown order. 更多... | |
| std::string | get_token () const |
| Returns the authentication token issued by this server. 更多... | |
Public 成员函数 继承自 vlink::MessageLoop | |
| MessageLoop () | |
Constructs a loop with the default kNormalType queue. 更多... | |
| MessageLoop (Type type) | |
| Constructs a loop with the given queue type. 更多... | |
| virtual | ~MessageLoop () |
| Destructor; requests quit and joins the dispatcher thread if needed. 更多... | |
| void | set_name (const std::string &name) |
| Sets a human-readable name visible to profiling tools. 更多... | |
| const std::string & | get_name () const |
Returns the loop name set via set_name. 更多... | |
| Type | get_type () const |
| Returns the queue type this loop was constructed with. 更多... | |
| Strategy | get_strategy () const |
| Returns the active back-pressure strategy. 更多... | |
| void | set_strategy (Strategy strategy) |
| Replaces the back-pressure strategy. 更多... | |
| void | register_begin_handler (Callback &&callback) |
| Registers a callback fired once at loop thread startup. 更多... | |
| void | register_end_handler (Callback &&callback) |
| Registers a callback fired once when the loop thread exits. 更多... | |
| void | register_idle_handler (Callback &&callback) |
| Registers a callback fired every time the queue becomes empty. 更多... | |
| bool | run () |
Runs the loop on the calling thread until quit is requested. 更多... | |
| bool | async_run () |
| Starts the loop on a new background thread. 更多... | |
| bool | spin () |
Alias of run blocking the calling thread. 更多... | |
| bool | spin_once (bool block=true) |
| Processes one batch of pending tasks and timers on the calling thread. 更多... | |
| bool | quit (bool force=false) |
| Requests the loop to exit. 更多... | |
| bool | wait_for_quit (int ms=Timer::kInfinite, bool check=true) |
| Waits until the loop has fully exited. 更多... | |
| bool | post_task (Callback &&callback) |
| Posts a task for execution on the loop thread. 更多... | |
| TaskHandle | post_task_handle (Callback &&callback, const PostTaskOptions &options={}) |
Tracked variant of post_task returning a TaskHandle. 更多... | |
| bool | post_task_with_priority (Callback &&callback, uint16_t priority) |
Posts a task with an explicit priority on a kPriorityType loop. 更多... | |
| TaskHandle | post_task_with_priority_handle (Callback &&callback, uint16_t priority, const PostTaskOptions &options={}) |
Tracked variant of post_task_with_priority returning a TaskHandle. 更多... | |
| 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. 更多... | |
| 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. 更多... | |
| bool | wakeup () |
| Wakes the loop thread if it is suspended in its idle wait. 更多... | |
| void | reset_lockfree_capacity () |
| Recreates the lock-free queue, clearing all queued tasks and counters. 更多... | |
| bool | is_running () const |
| Reports whether the loop is currently running. 更多... | |
| bool | is_ready_to_quit () const |
Reports whether quit has been requested and the loop is winding down. 更多... | |
| bool | is_busy () const |
| Reports whether the loop is currently executing a task. 更多... | |
| size_t | get_task_count () const |
| Returns the current pending task count. 更多... | |
| 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. 更多... | |
| virtual size_t | get_max_timer_count () const |
| Returns the maximum number of timers that can be attached. 更多... | |
| virtual bool | is_in_same_thread () const |
| Reports whether the calling thread is owned by this loop. 更多... | |
| std::shared_ptr< AliveState > | get_alive_state () const |
| Returns the shared lifetime flag used by cross-thread bridges. 更多... | |
| 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) |
Priority variant of invoke_task; requires a kPriorityType loop. 更多... | |
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 |
| Hook invoked once on the loop thread before the first task runs. 更多... | |
| void | on_end () override |
| Hook invoked once on the loop thread after the last task runs. 更多... | |
Protected 成员函数 继承自 vlink::MessageLoop | |
| virtual void | on_idle () |
| Hook invoked on the loop thread each time the queue becomes empty. 更多... | |
| virtual void | on_task_changed (Callback &&callback, uint32_t start_time) |
| Dispatches a ready task on the loop thread. 更多... | |
| virtual void | on_task_timeout (Callback &&callback, uint32_t elapsed_time) |
Hook invoked when a task exceeds get_max_elapsed_time(). 更多... | |
额外继承的成员函数 | |
Public 类型 继承自 vlink::MessageLoop | |
| enum | Type : uint8_t { kNormalType = 0 , kLockfreeType = 1 , kPriorityType = 2 } |
| Internal queue implementation type. 更多... | |
| enum | Strategy : uint8_t { kOptimizationStrategy = 0 , kPopStrategy = 1 , kBlockStrategy = 2 } |
| Back-pressure strategy applied when the bounded queue is at capacity. 更多... | |
| 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. 更多... | |
| using | Callback = MoveFunction< void()> |
| Callback type for tasks and event handlers. 更多... | |
In-process VLink proxy daemon backed by a MessageLoop.
Owns the discovery layer, the handshake/control/time/info DDS channels, the data relay path, and any embedded Iceoryx daemon or runnable plugins. Construction starts the DiscoveryViewer plus its 1-second heartbeat and statistics timers, but it does not start the server's own inherited loop. Call async_run() (or run()) on the MessageLoop base to enable asynchronous relays and the runnable-plugin lifecycle hooks. Only one instance is allowed per process.
|
explicit |
Constructs a ProxyServer and brings every proxy subsystem online.
The constructor performs the following steps in order:
VLINK_INTRA_BIND environment variable.config.use_iox is true, calls init_shm_roudi() to spin up an embedded Iceoryx RouDi process.init_server() to create the handshake, control, time, info, and data channels, subscribe to Control, and start the heartbeat plus statistics timers on the DiscoveryViewer's loop.init_runnable() to load every plugin listed in config.runnable_list.The inherited MessageLoop is not started here – call async_run() or run() explicitly when asynchronous relays and plugin lifecycle hooks must run.
ProxyServer in the same process is unsupported and the constructor throws.
|
override |
Destroys the ProxyServer in a deterministic shutdown order.
Requests the inherited MessageLoop to stop, waits for it, then stops the proxy timers, joins the DiscoveryViewer, and releases each DDS/SHM handle. When the loop has been started, runnable plugins receive on_deinit(), quit(), and wait_for_quit() from on_end() before the destructor drops them. The process-global singleton guard remains set for the rest of the process lifetime.
|
overrideprotectedvirtual |
Returns the maximum allowed task execution time in milliseconds.
Tasks exceeding this duration trigger on_task_timeout. Zero disables the check.
重载 vlink::MessageLoop .
|
overrideprotectedvirtual |
| std::string vlink::ProxyServer::get_token | ( | ) | const |
Returns the authentication token issued by this server.
When VLINK_PROXY_ENABLE_HANDSHAKE is non-zero (the default), the token is generated once at construction via vlink::Uuid::random_hex() and remains constant for the server's lifetime. Clients learn it through the security-authenticated handshake RPC. The server then validates the token on every inbound Control and echoes it (alongside the server identity) inside every Time heartbeat so clients can detect both server restarts and identity mismatches. When the macro is 0, the token is empty, validation is disabled, and the handshake channel is not created.
|
overrideprotectedvirtual |
Hook invoked once on the loop thread before the first task runs.
Subclasses override to perform per-thread initialisation.
重载 vlink::MessageLoop .
|
overrideprotectedvirtual |
Hook invoked once on the loop thread after the last task runs.
Subclasses override to perform per-thread cleanup.
重载 vlink::MessageLoop .