Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
FdHubPortBase Class Referenceabstract

Template-nonspecific base class for FdHubPort. More...

#include <HubDevice.hxx>

Inheritance diagram for FdHubPortBase:
FdHubPortInterface Atomic Destructable FdHubPort< HFlow >

Classes

class  ReadThreadBase
 Read thread implementation with template-inspecific methods. More...
 

Public Member Functions

 FdHubPortBase (int fd, Notifiable *done)
 Constructor.
 
- Public Member Functions inherited from FdHubPortInterface
int fd ()
 

Static Public Member Functions

static void fill_thread_name (char *buf, char mode, int fd)
 Puts the desired thread name for the read or write thread.
 

Static Public Attributes

static const int kWriteThreadStackSize = 1000
 How many bytes of stack should we allocate to the write thread's stack.
 
static const int kReadThreadStackSize = 1000
 How many bytes of stack should we allocate to the read thread's stack.
 

Protected Member Functions

const char * fill_thread_name (char mode, int fd)
 Puts the desired thread name for the read or write thread.
 
virtual void unregister_write_port ()=0
 Removes the write flow from the hub's registration.
 
void report_error ()
 Call when an IO error is encountered.
 
- Protected Member Functions inherited from FdHubPortInterface
 FdHubPortInterface (int fd)
 

Protected Attributes

char threadName_ [30]
 Temporary buffer used for rendering thread names.
 
Executor< 1 > writeThread_
 This executor is running the writes.
 
Service writeService_
 Service for the write flow.
 
BarrierNotifiable barrier_
 This barrier will be notified when both read and write thread has exited.
 
unsigned hasError_: 1
 If this is 1, the fd has been closed.
 
unsigned writeExitEnqueued_: 1
 If this is 1, we have already enqueued the request to exit the write flow.
 
- Protected Attributes inherited from FdHubPortInterface
int fd_ {-1}
 The device file descriptor.
 

Friends

template<class Data >
class FdHubWriteFlow
 

Additional Inherited Members

- Private Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 

Detailed Description

Template-nonspecific base class for FdHubPort.

The purpose of this class is to avoid compiling this code multiple times for differently typed devices (and thus saving flash space).

Definition at line 48 of file HubDevice.hxx.

Constructor & Destructor Documentation

◆ FdHubPortBase()

FdHubPortBase::FdHubPortBase ( int  fd,
Notifiable done 
)
inline

Constructor.

Parameters
fdis the filedes to read/write
donewill be called when this file is closed and removed from the hub (usually due to an error).

Definition at line 68 of file HubDevice.hxx.

◆ ~FdHubPortBase()

virtual FdHubPortBase::~FdHubPortBase ( )
inlinevirtual

Definition at line 79 of file HubDevice.hxx.

Member Function Documentation

◆ fill_thread_name() [1/2]

void FdHubPortBase::fill_thread_name ( char *  buf,
char  mode,
int  fd 
)
static

Puts the desired thread name for the read or write thread.

Parameters
bufwhere to put ocmputed thread name. Must be at least 15 chars long.
modea character describing read ('R') or write ('W')
fdfiledes number that will be rendered into the thread name.

Definition at line 96 of file HubDevice.cxx.

◆ fill_thread_name() [2/2]

const char * FdHubPortBase::fill_thread_name ( char  mode,
int  fd 
)
inlineprotected

Puts the desired thread name for the read or write thread.

Parameters
modea character describing read ('R') or write ('W')
fdfiledes number that will be rendered into the thread name.
Returns
the thread name buffer.

Definition at line 98 of file HubDevice.hxx.

◆ report_error()

void FdHubPortBase::report_error ( )
inlineprotected

Call when an IO error is encountered.

Closes the FD, unregisters the port from the hub and causes the threads to exit.

Definition at line 110 of file HubDevice.hxx.

◆ unregister_write_port()

virtual void FdHubPortBase::unregister_write_port ( )
protectedpure virtual

Removes the write flow from the hub's registration.

Triggers the write flow to call barrier_ when all the pending queue entries are released.

Implemented in FdHubPort< HFlow >.

Friends And Related Symbol Documentation

◆ FdHubWriteFlow

template<class Data >
friend class FdHubWriteFlow
friend

Definition at line 195 of file HubDevice.hxx.

Member Data Documentation

◆ barrier_

BarrierNotifiable FdHubPortBase::barrier_
protected

This barrier will be notified when both read and write thread has exited.

Definition at line 205 of file HubDevice.hxx.

◆ hasError_

unsigned FdHubPortBase::hasError_
protected

If this is 1, the fd has been closed.

Definition at line 207 of file HubDevice.hxx.

◆ kReadThreadStackSize

const int FdHubPortBase::kReadThreadStackSize = 1000
static

How many bytes of stack should we allocate to the read thread's stack.

Definition at line 61 of file HubDevice.hxx.

◆ kWriteThreadStackSize

const int FdHubPortBase::kWriteThreadStackSize = 1000
static

How many bytes of stack should we allocate to the write thread's stack.

Definition at line 59 of file HubDevice.hxx.

◆ threadName_

char FdHubPortBase::threadName_[30]
protected

Temporary buffer used for rendering thread names.

Definition at line 198 of file HubDevice.hxx.

◆ writeExitEnqueued_

unsigned FdHubPortBase::writeExitEnqueued_
protected

If this is 1, we have already enqueued the request to exit the write flow.

Definition at line 210 of file HubDevice.hxx.

◆ writeService_

Service FdHubPortBase::writeService_
protected

Service for the write flow.

Definition at line 202 of file HubDevice.hxx.

◆ writeThread_

Executor<1> FdHubPortBase::writeThread_
protected

This executor is running the writes.

Definition at line 200 of file HubDevice.hxx.


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