hmbdc
simplify-high-performance-messaging-programming
 All Classes Namespaces Functions Variables Friends Pages
Public Member Functions | Protected Member Functions | List of all members
hmbdc::app::ClientWithStash< CcClient, MaxStashedMessageSizeIn, Messages > Class Template Reference

It behaves like Client, with the extra capability of storing messages received and processing them later - it is used when the user wants to process messages in a specific order other than FIFO. If a message is deemed to come too early, just stash it and move on (to the next message). The stashed messages will be delivered later at the user's choice - see the added stash and openStash functions. The stash mechanism can enforce any particular order of message processing regarless of the order of message being sent. More...

#include <ClientWithStash.hpp>

Inheritance diagram for hmbdc::app::ClientWithStash< CcClient, MaxStashedMessageSizeIn, Messages >:
hmbdc::app::Client< CcClient, Messages...>

Public Member Functions

template<MessageC Message>
void stash (Message const &message)
 stash a message that will be delivered later to the same callback More...
 
template<typename Iterator >
void handleRangeImpl (Iterator it, Iterator end, uint16_t threadId)
 do not touch - internal use
 
- Public Member Functions inherited from hmbdc::app::Client< CcClient, Messages...>
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...
 
virtual void messageDispatchingStartedCb (uint16_t threadSerialNumber)
 called before any messages got dispatched - only once More...
 
virtual void stoppedCb (std::exception const &e)
 callback called when this Client is taken out of message dispatching More...
 
virtual bool droppedCb ()
 callback called after the Client is safely taken out of the Context More...
 
virtual void invokedCb (uint16_t threadSerialNumber)
 this callback is called all the time (frequently) - the exact timing is after a batch of messages are dispatched. After this call returns, the previously dispatched message's addresses are no longer valid, which means if you cache the event addresses in the previous handleMessageCb()s, you cannot use those after the return of the next invokeCb function. More...
 
virtual ~Client ()
 trivial
 
void stopped (std::exception const &e) noexcept
 the following are for internal use, don't change or override
 

Protected Member Functions

void openStash ()
 release the stashed messages - after this call is returned, the callbacks of the stahsed message will be invoked with the stashed messages More...
 
- Protected Member Functions inherited from hmbdc::app::Client< CcClient, Messages...>
void batchDone ()
 the derived user's Client has the option to stop the current batch of event dispatching. More...
 

Detailed Description

template<typename CcClient, size_t MaxStashedMessageSizeIn, MessageC... Messages>
class hmbdc::app::ClientWithStash< CcClient, MaxStashedMessageSizeIn, Messages >

It behaves like Client, with the extra capability of storing messages received and processing them later - it is used when the user wants to process messages in a specific order other than FIFO. If a message is deemed to come too early, just stash it and move on (to the next message). The stashed messages will be delivered later at the user's choice - see the added stash and openStash functions. The stash mechanism can enforce any particular order of message processing regarless of the order of message being sent.

Template Parameters
CcClientthe concrete Client type
MaxStashedMessageSizeInbyte size of the max message that will need to be stashed, use 0 to auto-set to hold the max interested message
typename... Messages message types that the Client interested

Member Function Documentation

template<typename CcClient , size_t MaxStashedMessageSizeIn, MessageC... Messages>
void hmbdc::app::ClientWithStash< CcClient, MaxStashedMessageSizeIn, Messages >::openStash ( )
inlineprotected

release the stashed messages - after this call is returned, the callbacks of the stahsed message will be invoked with the stashed messages

it is fine to stash more / new messages even in the above callbacks invoked due to stashed messages

template<typename CcClient , size_t MaxStashedMessageSizeIn, MessageC... Messages>
template<MessageC Message>
void hmbdc::app::ClientWithStash< CcClient, MaxStashedMessageSizeIn, Messages >::stash ( Message const &  message)
inline

stash a message that will be delivered later to the same callback

when the Client decide a message is not ready to be handled now but is needed later, it calls this message to stash it, see also openStash()

Parameters
messagethe message to be stashed

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