1 #include "hmbdc/Copyright.hpp" 4 #include "hmbdc/app/Client.hpp" 5 #include "hmbdc/app/Message.hpp" 9 namespace hmbdc {
namespace app {
24 template <
typename CcClient,
size_t MaxStashedMessageSizeIn, MessageC ... Messages>
26 :
Client<CcClient, Messages...> {
28 using Interests =
typename Base::Interests;
31 MaxStashedMessageSize = MaxStashedMessageSizeIn
32 ?MaxStashedMessageSizeIn
44 template <MessageC Message>
45 void stash(Message
const& message) {
46 static_assert(
index_in_tuple<Message, std::tuple<Messages...>>::value !=
sizeof...(Messages)
47 ,
"cannot stash uninterested message");
48 stash_.push_back(
typename decltype(stash_)::value_type{});
60 stashOpenCount_ = stash_.size();
65 CcClient& c =
static_cast<CcClient&
>(*this);
66 while (hmbdc_unlikely(stashOpenCount_)) {
73 size_t stashOpenCount_ = 0;
74 std::deque<std::array<char, MaxStashedMessageSize + sizeof(MessageHead)>> stash_;
80 template <
typename Iterator>
82 auto res = Base::handleRangeImpl(it, end, threadId);
Definition: MetaUtils.hpp:48
Definition: MessageDispacher.hpp:184
void openStash()
release the stashed messages - after this call is returned, the callbacks of the stahsed message will...
Definition: ClientWithStash.hpp:59
Definition: Message.hpp:212
size_t handleRangeImpl(Iterator it, Iterator end, uint16_t threadId)
do not touch - internal use
Definition: ClientWithStash.hpp:81
Definition: Message.hpp:263
Definition: MetaUtils.hpp:100
It behaves like Client, with the extra capability of storing messages received and processing them la...
Definition: ClientWithStash.hpp:25
A Client represents a thread of execution/a task. The execution is managed by a Context. a Client object could participate in message dispatching as the receiver of specifed message types.
Definition: Client.hpp:122
a std tuple holding messages types it can dispatch
Definition: BlockingContext.hpp:206
void stash(Message const &message)
stash a message that will be delivered later to the same callback
Definition: ClientWithStash.hpp:45