VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
ack_manager.h 文件参考

Request/acknowledgement synchronisation manager for blocking RPC calls. 更多...

#include <functional>
#include <memory>
#include <mutex>
#include <set>
#include "../base/condition_variable.h"
#include "../base/macros.h"
ack_manager.h 的引用(Include)关系图:

浏览该文件的源代码.

 Thread-safe request/acknowledgement synchronisation manager. 更多...

命名空间

详细描述

Request/acknowledgement synchronisation manager for blocking RPC calls.

AckManager provides the blocking/notify mechanism used by the VLink method model (Client / Server) to implement synchronous request/response round-trips across transports. A caller creates a Request token, invokes process() to send the request and wait for its acknowledgement, and either the transport callback calls notify() on the same request or the caller can cancel it via remove().

Lifecycle
Thread A (caller) Thread B (transport callback)
request = create_request()
process(request, timeout_ms, send_fn)
-> send_fn() publishes the request
-> blocks on condition variable
notify(request, fill_response_fn)
-> erase request from set
-> call fill_response_fn()
-> notify_one on the cv
-> wakes up, returns true
Interruption
clear() marks the manager as interrupted and wakes all waiting process() callers, causing them to return false. This is used during shutdown to unblock any in-flight RPC calls.
Thread Safety
All public methods are thread-safe. process() may be called from multiple threads simultaneously; each call tracks its own RequestPtr.