8 : m_token(token), m_pending_replies(std::move(ptr)) {
17 if (
auto pending = m_pending_replies.lock(); pending) {
18 pending->Release(m_token);
27 return !m_pending.empty();
31 std::vector<PendingReply> r;
32 r.reserve(m_pending.size());
33 std::transform(m_pending.begin(), m_pending.end(), std::back_inserter(r),
34 [](
auto const& tup) ->
PendingReply { return std::get<1>(tup); });
39 auto token = m_next_token_id++;
40 m_pending.emplace_back(std::tuple<uint64_t, PendingReply>(
41 {token,
PendingReply{std::move(source_id), std::move(request)}}));
46 std::string request) {
47 auto token = m_next_token_id++;
48 m_pending.emplace_back(std::tuple<uint64_t, PendingReply>(
49 {token,
PendingReply{std::move(source_id), std::move(request)}}));
50 return std::shared_ptr<ReplyToken>(
new ReplyToken(token, shared_from_this()));
55 std::remove_if(m_pending.begin(), m_pending.end(),
56 [=](
auto const& tup) ->
bool {
57 return std::get<0>(tup) == token; }),
static std::shared_ptr< PendingReplies > Create()
Create instance.
void Release(uint64_t token)
ReplyToken Acquire(std::string source_id, std::string request)
Acquire token.
bool HasPendingReplies() const
std::shared_ptr< ReplyToken > AcquireShared(std::string source_id, std::string request)
std::vector< PendingReply > GetPendingReplies() const
Token representing a not-yet-received reply.
void Release()
Release token explicitly.
ReplyToken(ReplyToken &&)=default
Contains declaration for classes related to pending replies.