blob: 1028d46aff4dc60a130ba0eccc68fcdc07ef00e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "replygate.h"
#include "message.h"
#include "reply.h"
namespace mbus {
ReplyGate::ReplyGate(IMessageHandler &sender) :
_sender(sender),
_open(true)
{ }
void
ReplyGate::handleMessage(Message::UP msg)
{
internal_addref();
msg->pushHandler(*this, *this);
_sender.handleMessage(std::move(msg));
}
void
ReplyGate::close()
{
_open.store(false, std::memory_order_relaxed);
}
void
ReplyGate::handleReply(Reply::UP reply)
{
if (_open.load(std::memory_order_relaxed)) {
IReplyHandler &handler = reply->getCallStack().pop(*reply);
handler.handleReply(std::move(reply));
} else {
reply->discard();
}
internal_subref();
}
void
ReplyGate::handleDiscard(Context)
{
internal_subref();
}
} // namespace mbus
|