198 struct Request final {
205 if (!left || !right) {
209 return left->seq < right->seq;
214 bool is_interrupted_{
false};
215 int64_t request_seq_{0};
216 mutable std::mutex mtx_;
217 std::set<RequestPtr, Request::Compare> request_set_;
std::function< void()> NotifyCallback
Optional callback invoked inside notify() while holding the request lock.
Definition ack_manager.h:104
bool process(RequestPtr request, int ms, ProcessCallback &&process_callback) noexcept
Registers the request, invokes the send callback, and blocks until acknowledged.
bool remove(RequestPtr request) noexcept
Removes a pending request without notifying the waiting caller.
std::function< bool()> ProcessCallback
Callback invoked by process() to send the request over the transport.
Definition ack_manager.h:95
void clear() noexcept
Interrupts all pending requests and wakes all blocked process() calls.
AckManager() noexcept
Default constructor.
bool notify(RequestPtr request, NotifyCallback &¬ify_callback=nullptr) noexcept
Acknowledges a pending request and optionally fills the response.
RequestPtr create_request() noexcept
Allocates a new in-flight request token with a unique sequence number.
std::shared_ptr< Request > RequestPtr
Shared ownership handle for an in-flight request token.
Definition ack_manager.h:113
POSIX monotonic-clock condition variable replacing std::condition_variable.
Platform-independent macro definitions for the VLink library.
#define VLINK_EXPORT
Definition macros.h:85
#define VLINK_DISALLOW_COPY_AND_ASSIGN(classname)
Deletes the copy constructor and copy-assignment operator of classname.
Definition macros.h:184
ConditionVariable condition_variable
Definition condition_variable.h:686
Definition ack_manager.h:203
bool operator()(const RequestPtr &left, const RequestPtr &right) const noexcept
Definition ack_manager.h:204