mirror of https://github.com/oxen-io/oxen-mq.git
add operator() overload for defered message that sends reply
This commit is contained in:
parent
e1b1a84c4b
commit
5a41e84378
|
@ -75,6 +75,15 @@ public:
|
|||
|
||||
explicit DeferredSend(Message& m) : oxenmq{m.oxenmq}, conn{m.conn}, reply_tag{m.reply_tag} {}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(Args &&...args) const {
|
||||
if (reply_tag.empty())
|
||||
back(std::forward<Args>(args)...);
|
||||
else
|
||||
reply(std::forward<Args>(args)...);
|
||||
};
|
||||
|
||||
|
||||
/// Equivalent to msg.send_back(...), but can be invoked later.
|
||||
template <typename... Args>
|
||||
void back(std::string_view command, Args&&... args) const;
|
||||
|
|
|
@ -472,7 +472,7 @@ TEST_CASE("deferred replies", "[commands][send][deferred]") {
|
|||
{ auto lock = catch_lock(); UNSCOPED_INFO("sleeping"); }
|
||||
std::this_thread::sleep_for(50ms * TIME_DILATION);
|
||||
{ auto lock = catch_lock(); UNSCOPED_INFO("sending"); }
|
||||
send.reply(msg);
|
||||
send(msg);
|
||||
}};
|
||||
t.detach();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue