1 #include "hmbdc/Copyright.hpp" 4 #include "hmbdc/app/MessageDispacher.hpp" 5 #include "hmbdc/MetaUtils.hpp" 6 #include "hmbdc/Compile.hpp" 10 #include <type_traits> 12 namespace hmbdc {
namespace app {
56 template <
typename CcClient, MessageC ... Messages>
66 INTERESTS_SIZE = std::tuple_size<Interests>::value,
75 char const*
hmbdcName()
const {
return "hmbdc-anonymous"; }
87 return std::make_tuple<char const*, int>(
nullptr, 0);
89 return std::make_tuple<char const*, int>(
nullptr, 20);
129 std::cerr <<
"Client " << hmbdcName()
130 <<
" exited with reason: " << e.what() << std::endl;
182 void stopped(std::exception
const&e) noexcept {
188 bool dropped() noexcept {
196 template <
typename Iterator>
197 size_t handleRangeImpl(Iterator it,
198 Iterator end, uint16_t threadId) {
199 CcClient& c =
static_cast<CcClient&
>(*this);
201 for (;hmbdc_likely(!batchDone_ && it != end); ++it) {
202 if (MessageDispacher<CcClient, Interests>()(
210 bool batchDone_ =
false;
virtual void invokedCb(size_t dispatched)
this callback is called all the time (frequently) - the exact timing is after a batch of messages are...
Definition: Client.hpp:155
char const * hmbdcName() const
return the name of thread that runs this client, override if necessary
Definition: Client.hpp:75
virtual ~Client()
trivial
Definition: Client.hpp:162
std::tuple< char const *, int > schedSpec() const
an overrideable method. returns the schedule policy and priority, override if necessary priority is o...
Definition: Client.hpp:85
template that convert a regular message to be a reply used in request / reply sync messaging - see Re...
Definition: Message.hpp:363
virtual bool droppedCb()
callback called after the Client is safely taken out of the Context
Definition: Client.hpp:139
a std tuple holding REPLY messages types it can dispatch
void batchDone()
the derived user's Client has the option to stop the current batch of event dispatching.
Definition: Client.hpp:174
void stopped(std::exception const &e) noexcept
the following are for internal use, don't change or override
Definition: Client.hpp:182
Definition: Message.hpp:78
Definition: MetaUtils.hpp:205
size_t maxBatchMessageCount() const
an overridable method. client receives events in batches and the max batch size is controllable when ...
Definition: Client.hpp:101
virtual void stoppedCb(std::exception const &e)
callback called when this Client is taken out of message dispatching
Definition: Client.hpp:127
virtual void messageDispatchingStartedCb(uint16_t threadSerialNumber)
called before any messages got dispatched - only once
Definition: Client.hpp:113
a trait class, if a Client can only run on a single specific thread in Pool, derive the Client from i...
Definition: Client.hpp:19
Definition: MetaUtils.hpp:187
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:57
a std tuple holding messages types it can dispatch except REPLYs
Definition: BlockingContext.hpp:183
a std tuple holding REQUEST messages types it can dispatch
template that convert a regular message to be a request used in request / reply sync messaging - see ...
Definition: Message.hpp:339