|
VLink
2.0.0
A high-performance communication middleware
|
Thread-safe coordinator that pairs RPC requests with their acknowledgements. 更多...
#include <ack_manager.h>
Public 类型 | |
| using | ProcessCallback = MoveFunction< bool()> |
Send callback supplied to process(); returning false aborts the wait. 更多... | |
| using | NotifyCallback = MoveFunction< void()> |
Optional fill-in callback invoked from inside notify() under the lock. 更多... | |
| using | RequestPtr = std::shared_ptr< Request > |
| Shared handle representing a single in-flight RPC request. 更多... | |
Public 成员函数 | |
| AckManager () noexcept | |
| Constructs an empty manager. 更多... | |
| ~AckManager () noexcept | |
| Destroys the manager and releases any remaining pending records. 更多... | |
| RequestPtr | create_request () noexcept |
| Allocates a new request token with the next monotonic sequence number. 更多... | |
| bool | process (RequestPtr request, int ms, ProcessCallback &&process_callback) noexcept |
Publishes request via process_callback and blocks until it is acknowledged. 更多... | |
| bool | notify (RequestPtr request, NotifyCallback &¬ify_callback=nullptr) noexcept |
Resolves request and, if supplied, runs notify_callback before waking the caller. 更多... | |
| bool | remove (RequestPtr request) noexcept |
Cancels request without waking any waiter. 更多... | |
| void | clear () noexcept |
Interrupts every pending wait and refuses new ones until reset_interrupted(). 更多... | |
| void | reset_interrupted () noexcept |
Permits new process() calls again after a previous clear(). 更多... | |
Thread-safe coordinator that pairs RPC requests with their acknowledgements.
Stores a sorted set of in-flight RequestPtr handles indexed by their sequence number and uses one condition variable per request to wake the blocked caller when notify() arrives. Used internally by every ClientImpl subclass to provide the blocking call() semantics exposed at the public Client API.
| using vlink::AckManager::NotifyCallback = MoveFunction<void()> |
Optional fill-in callback invoked from inside notify() under the lock.
Lets the transport copy the response into the caller's buffer before the waiting thread is resumed. May be nullptr.
| using vlink::AckManager::ProcessCallback = MoveFunction<bool()> |
| using vlink::AckManager::RequestPtr = std::shared_ptr<Request> |
Shared handle representing a single in-flight RPC request.
Returned by create_request() and consumed by process(), notify() and remove(). Equality is implied by the monotonic sequence number.
|
noexcept |
Constructs an empty manager.
|
noexcept |
Destroys the manager and releases any remaining pending records.
|
noexcept |
Interrupts every pending wait and refuses new ones until reset_interrupted().
Bumps the generation counter, drains the pending set into a local copy and notifies every condition variable so that the affected process() calls return false. Used during node shutdown to avoid blocking destructors.
|
noexcept |
Allocates a new request token with the next monotonic sequence number.
process().
|
noexcept |
Resolves request and, if supplied, runs notify_callback before waking the caller.
Erases the entry from the pending set, executes notify_callback while holding the request lock so the caller observes the side effects before resuming, and signals the condition variable.
| request | Token to acknowledge. |
| notify_callback | Optional callable executed before notification. |
true if the request was still pending and was resolved; false otherwise.
|
noexcept |
Publishes request via process_callback and blocks until it is acknowledged.
The method performs four steps:
request in the pending set; returns false straight away if clear() has been called and not yet reset.process_callback to dispatch the request. When the callback returns false the entry is removed and process() also returns false.notify() / remove() fires or ms expires. A negative ms blocks forever.true on a successful notify(); false on timeout, abort or clear() interruption.| request | Token obtained from create_request(). |
| ms | Wait budget in milliseconds; negative for unlimited. |
| process_callback | Send callback; returning false aborts the wait. |
true on acknowledgement, false otherwise.
|
noexcept |
Cancels request without waking any waiter.
| request | Token to drop from the pending set. |
true if the entry existed and was removed; false otherwise.
|
noexcept |