Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::EventIteratorFlow Class Reference

Flow to receive incoming messages of event protocol, and dispatch them to the registered event handler. More...

#include <EventServiceImpl.hxx>

Inheritance diagram for openlcb::EventIteratorFlow:
openlcb::IncomingMessageStateFlow StateFlow< Buffer< GenMessage >, QList< 4 > > TypedStateFlow< MessageType, Base > FlowInterface< MessageType > openlcb::InlineEventIteratorFlow

Public Member Functions

 EventIteratorFlow (If *iface, EventService *event_service, unsigned mti_value, unsigned mti_mask)
 
- Public Member Functions inherited from openlcb::IncomingMessageStateFlow
 IncomingMessageStateFlow (If *iface)
 
Ififace ()
 
GenMessagenmsg ()
 Returns the NMRAnet message we received.
 
- Public Member Functions inherited from StateFlow< Buffer< GenMessage >, QList< 4 > >
 StateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from TypedStateFlow< MessageType, Base >
 TypedStateFlow (Service *service)
 Constructor.
 
virtual ~TypedStateFlow ()
 Destructor.
 
void send (MessageType *msg, unsigned priority=UINT_MAX) OVERRIDE
 Sends a message to the state flow for processing.
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Protected Member Functions

Action entry () OVERRIDE
 Entry into the StateFlow activity.
 
Action iterate_next ()
 
- Protected Member Functions inherited from TypedStateFlow< MessageType, Base >
void release () OVERRIDE
 Unrefs the current buffer.
 
void return_buffer ()
 For state flows that are operated using invoke_subflow_and_wait this is a way to hand back the buffer to the caller.
 
MessageType * message ()
 
MessageType * transfer_message ()
 Releases ownership of the current message.
 

Protected Attributes

EventServiceeventService_
 
EventReport eventReport_
 Statically allocated structure for calling the event handlers from the main event queue.
 
EventIteratoriterator_
 Iterator for generating the event handlers from the registry.
 
NotifiableincomingDone_
 This done notifiable holds a reference to the incoming message buffer.
 
unsigned eventRegistryEpoch_
 The epoch of the event registry at the start of the iteration.
 
BarrierNotifiable n_
 
EventHandlerFunction fn_
 
uint8_t countEvents_ {0}
 How many events' cost are accumulated so far.
 
uint16_t mtiValue_
 
long long numProcessNsec_ {0}
 Accumulator of how many msec processingthe events took.
 
long long currentProcessStart_ {0}
 When the processing of the current event started.
 

Static Protected Attributes

static const int REPORT_COUNT = 100
 

Private Member Functions

virtual Action dispatch_event (const EventRegistryEntry *entry)
 

Additional Inherited Members

- Public Types inherited from TypedStateFlow< MessageType, Base >
typedef Base::Action Action
 Allows using Action without having StateFlowBase:: prefix in front of it.
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 
- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 

Detailed Description

Flow to receive incoming messages of event protocol, and dispatch them to the registered event handler.

This flow runs on the executor of the event service (and not necessarily the interface). Its main job is to iterate through the matching event handler and call each of them for that report.

Definition at line 127 of file EventServiceImpl.hxx.

Constructor & Destructor Documentation

◆ EventIteratorFlow()

openlcb::EventIteratorFlow::EventIteratorFlow ( If iface,
EventService event_service,
unsigned  mti_value,
unsigned  mti_mask 
)

Definition at line 88 of file EventService.cxx.

◆ ~EventIteratorFlow()

openlcb::EventIteratorFlow::~EventIteratorFlow ( )

Definition at line 100 of file EventService.cxx.

Member Function Documentation

◆ dispatch_event()

StateFlowBase::Action openlcb::EventIteratorFlow::dispatch_event ( const EventRegistryEntry entry)
privatevirtual

Definition at line 278 of file EventService.cxx.

◆ entry()

StateFlowBase::Action openlcb::EventIteratorFlow::entry ( )
protectedvirtual

Entry into the StateFlow activity.

Pure virtual which must be defined by derived class.

Returns
function pointer to next state

@TODO(balazs.racz) refactor this into a global constant.

Implements TypedStateFlow< MessageType, Base >.

Definition at line 131 of file EventService.cxx.

◆ iterate_next()

StateFlowBase::Action openlcb::EventIteratorFlow::iterate_next ( )
protected

Definition at line 238 of file EventService.cxx.

Member Data Documentation

◆ countEvents_

uint8_t openlcb::EventIteratorFlow::countEvents_ {0}
protected

How many events' cost are accumulated so far.

Definition at line 164 of file EventServiceImpl.hxx.

◆ currentProcessStart_

long long openlcb::EventIteratorFlow::currentProcessStart_ {0}
protected

When the processing of the current event started.

Definition at line 169 of file EventServiceImpl.hxx.

◆ eventRegistryEpoch_

unsigned openlcb::EventIteratorFlow::eventRegistryEpoch_
protected

The epoch of the event registry at the start of the iteration.

Used to recognize when the iterators are invalidated.

Definition at line 156 of file EventServiceImpl.hxx.

◆ eventReport_

EventReport openlcb::EventIteratorFlow::eventReport_
protected

Statically allocated structure for calling the event handlers from the main event queue.

Definition at line 146 of file EventServiceImpl.hxx.

◆ eventService_

EventService* openlcb::EventIteratorFlow::eventService_
protected

Definition at line 142 of file EventServiceImpl.hxx.

◆ fn_

EventHandlerFunction openlcb::EventIteratorFlow::fn_
protected

Definition at line 159 of file EventServiceImpl.hxx.

◆ incomingDone_

Notifiable* openlcb::EventIteratorFlow::incomingDone_
protected

This done notifiable holds a reference to the incoming message buffer.

We must not release this notifiable until we have completed processing and freed all the buffers related to this iteration.

Definition at line 153 of file EventServiceImpl.hxx.

◆ iterator_

EventIterator* openlcb::EventIteratorFlow::iterator_
protected

Iterator for generating the event handlers from the registry.

Definition at line 149 of file EventServiceImpl.hxx.

◆ mtiValue_

uint16_t openlcb::EventIteratorFlow::mtiValue_
protected

Definition at line 165 of file EventServiceImpl.hxx.

◆ n_

BarrierNotifiable openlcb::EventIteratorFlow::n_
protected

Definition at line 158 of file EventServiceImpl.hxx.

◆ numProcessNsec_

long long openlcb::EventIteratorFlow::numProcessNsec_ {0}
protected

Accumulator of how many msec processingthe events took.

Definition at line 167 of file EventServiceImpl.hxx.

◆ REPORT_COUNT

const int openlcb::EventIteratorFlow::REPORT_COUNT = 100
staticprotected

Definition at line 162 of file EventServiceImpl.hxx.


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