Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
DirectHubService Class Reference

A single service class that is shared between all interconnected DirectHub instances. More...

Inheritance diagram for DirectHubService:
Service

Public Types

typedef Q QueueType
 

Public Member Functions

 DirectHubService (ExecutorBase *e)
 
Atomiclock ()
 
void enqueue_caller (Executable *caller)
 Adds a caller to the waiting list of who wants to send traffic to the hub.
 
void on_done ()
 This function must be called at the end of the enqueued functions in order to properly clear the busy flag or take out the next enqueued executable.
 
- Public Member Functions inherited from Service
 Service (ExecutorBase *e)
 Constructor.
 
 ~Service ()
 Destructor.
 
ExecutorBaseexecutor ()
 

Public Attributes

unsigned busy_: 1
 1 if there is any message being processed right now.
 
QueueType pendingSend_
 List of callers that are waiting for the busy_ lock.
 

Detailed Description

A single service class that is shared between all interconnected DirectHub instances.

It is the responsibility of this Service to perform the locking of the individual flows.

Definition at line 66 of file DirectHub.cxx.

Member Typedef Documentation

◆ QueueType

Definition at line 69 of file DirectHub.cxx.

Constructor & Destructor Documentation

◆ DirectHubService()

DirectHubService::DirectHubService ( ExecutorBase e)
inline

Definition at line 71 of file DirectHub.cxx.

Member Function Documentation

◆ enqueue_caller()

void DirectHubService::enqueue_caller ( Executable caller)
inline

Adds a caller to the waiting list of who wants to send traffic to the hub.

If there is no waiting list, the caller will be executed inline.

Parameters
callerrepresents an entry point to the hub. It is required that caller finishes its run() by invoking on_done().
Todo:
there is a short period of priority inversion here, because we insert an executable into a separate queue here than the Executor. We dequeue the highest priority in on_done(), but if that happens to be a low priority, that might get stuck in the Executor for a long time, even if in the meantime a higher priority message arrives here. A better strategy would be to enqueue the Executable's in the Service's executor directly instead of queueing them and pushing them one by one to the Service's executor. In that case we'd need a third state between busy and not busy: whether we're queueing executable's or whether we're dumping them into the executor. We would also need to keep track of how many went to the Executor already, such that we know when busy_ gets back to false.

Definition at line 87 of file DirectHub.cxx.

◆ lock()

Atomic * DirectHubService::lock ( )
inline
Returns
lock object for the busy_ flag.

Definition at line 78 of file DirectHub.cxx.

◆ on_done()

void DirectHubService::on_done ( )
inline

This function must be called at the end of the enqueued functions in order to properly clear the busy flag or take out the next enqueued executable.

Definition at line 118 of file DirectHub.cxx.

Member Data Documentation

◆ busy_

unsigned DirectHubService::busy_

1 if there is any message being processed right now.

Definition at line 136 of file DirectHub.cxx.

◆ pendingSend_

QueueType DirectHubService::pendingSend_

List of callers that are waiting for the busy_ lock.

Definition at line 138 of file DirectHub.cxx.


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