hmbdc
simplify-high-performance-messaging-programming
Public Types | Public Member Functions | List of all members
hmbdc::app::Client< CcClient, Messages > Struct Template Reference
Inheritance diagram for hmbdc::app::Client< CcClient, Messages >:
hmbdc::app::MessageHandler< CcClient, Messages... > hmbdc::pattern::PoolConsumer

Public Types

enum  { REGISTERED_MESSAGE_SIZE = sizeof...(Messages) }
 

Public Member Functions

 Client ()
 trivial constructor
 
void messageDispatchingStartedCb (uint16_t threadSerialNumber) override
 called before any messages got dispatched - only once More...
 
void stoppedCb (std::exception const &e) override
 callback called when this Client is taken out of message dispatching More...
 
bool droppedCb () override
 callback called after the Client is safely taken out of the Context More...
 
void invokedCb (uint16_t threadSerialNumber) override
 this callback is called all the time (frequently) More...
 
char const * hmbdcName () const
 return the name of thread that runs this client, override if necessary More...
 
std::tuple< char const *, int > schedSpec () const
 an overrideable method. returns the schedule policy and priority, override if necessary priority is only used when policy is "SCHED_RR", or "SCHED_FIFO" More...
 
size_t maxBatchMessageCount () const
 an overridable method. client receives events in batches and the max batch size is controllable when running in direct mode Context. Here is to specify the max size. More...
 
void handleRangeImpl (BufIt &it, BufIt const &end, uint16_t threadSerialNumber) override
 internal use, don't change or override
 
- Public Member Functions inherited from hmbdc::app::MessageHandler< CcClient, Messages... >
void handleMessage (MessageHead &w)
 
- Public Member Functions inherited from hmbdc::pattern::PoolConsumer
 PoolConsumer (bool interestedInMessages=true)
 
void stopped (std::exception const &) noexcept
 
bool dropped () noexcept
 
void messageDispatchingStarted (uint16_t threadId)
 
void invoked (uint16_t threadId)
 

Additional Inherited Members

- Static Public Member Functions inherited from hmbdc::app::MessageHandler< CcClient, Messages... >
static void tryDispatch (CcClient *p, MessageHead &w)
 
- Protected Types inherited from hmbdc::pattern::PoolConsumer
using BufIt = lf_misc::iterator< HMBDC_SEQ_TYPE >
 

Detailed Description

template<typename CcClient, typename... Messages>
struct hmbdc::app::Client< CcClient, Messages >

Examples:
chat.cpp, client-server-netmap.cpp, hello-world.cpp, hmbdc-log.cpp, hmbdc.cpp, ipc-market-data-propagate.cpp, perf-base-thru.cpp, and server-cluster.cpp.

Member Function Documentation

template<typename CcClient, typename... Messages>
bool hmbdc::app::Client< CcClient, Messages >::droppedCb ( )
inlineoverridevirtual

callback called after the Client is safely taken out of the Context

exception thrown here is ignored and return true is assumed

Returns
if false, this Client is added back to the Context to process messages otherwise, no more callback. You could even safely "delete this; return true;"

Reimplemented from hmbdc::pattern::PoolConsumer.

template<typename CcClient, typename... Messages>
char const* hmbdc::app::Client< CcClient, Messages >::hmbdcName ( ) const
inline

return the name of thread that runs this client, override if necessary

this only used when the Client is running in direct mode

Returns
thread name - default to be hmbdc0, hmbdc1 ...
template<typename CcClient, typename... Messages>
void hmbdc::app::Client< CcClient, Messages >::invokedCb ( uint16_t  threadSerialNumber)
inlineoverridevirtual

this callback is called all the time (frequently)

used if the Client needs to do something all the time like powering another message loop

Parameters
threadSerialNumberthe number indicating which thread is in action

Reimplemented from hmbdc::pattern::PoolConsumer.

template<typename CcClient, typename... Messages>
size_t hmbdc::app::Client< CcClient, Messages >::maxBatchMessageCount ( ) const
inline

an overridable method. client receives events in batches and the max batch size is controllable when running in direct mode Context. Here is to specify the max size.

a message could only be reaching one client when using partition Context. In this case, reduce the size (reduce the greediness) might be useful

Returns
the max number of messages when grabbing messages to process
template<typename CcClient, typename... Messages>
void hmbdc::app::Client< CcClient, Messages >::messageDispatchingStartedCb ( uint16_t  threadSerialNumber)
inlineoverridevirtual

called before any messages got dispatched - only once

this is the place some preparation code goes to

Parameters
threadSerialNumbernormally the number indicating which thread is in action, except when REGISTERED_MESSAGE_SIZE == 0 it is another undefined value

Reimplemented from hmbdc::pattern::PoolConsumer.

template<typename CcClient, typename... Messages>
std::tuple<char const*, int> hmbdc::app::Client< CcClient, Messages >::schedSpec ( ) const
inline

an overrideable method. returns the schedule policy and priority, override if necessary priority is only used when policy is "SCHED_RR", or "SCHED_FIFO"

this is only used when the Client is running in direct mode supported policy are "SCHED_OTHER"(=nullptr), "SCHED_RR", "SCHED_FIFO"

Returns
a tuple made of schedule policy and priority, default to be SCHED_OTHER
template<typename CcClient, typename... Messages>
void hmbdc::app::Client< CcClient, Messages >::stoppedCb ( std::exception const &  e)
inlineoverridevirtual

callback called when this Client is taken out of message dispatching

after this call the Client is still at hook from the Context point of view (until droppedCb is called), so don't delete this Client yet or add it back to the Context. any exception thrown here is ignored,

Parameters
ethe exception that caused the Client to be taken out of message dispatching e could be thrown by the Client itself in a callback function to voluntarily take itself out

Reimplemented from hmbdc::pattern::PoolConsumer.


The documentation for this struct was generated from the following file: