VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
ack_manager.h File Reference

Request/acknowledgement synchronisation manager for blocking RPC calls. More...

#include <functional>
#include <memory>
#include <mutex>
#include <set>
#include "../base/condition_variable.h"
#include "../base/macros.h"
Include dependency graph for ack_manager.h:

Go to the source code of this file.

Classes

 Thread-safe request/acknowledgement synchronisation manager. More...

Namespaces

Detailed Description

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.