Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
FdHubPort< HFlow > Class Template Reference

HubPort that connects a raw device to a strongly typed Hub. More...

#include <HubDevice.hxx>

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

Classes

class  ReadThread
 Thread performing the read operations on the device. More...
 

Public Member Functions

 FdHubPort (HFlow *hub, int fd, Notifiable *done)
 Constructor.
 
void unregister_write_port () OVERRIDE
 Removes the write flow from the hub's registration.
 
- Public Member Functions inherited from FdHubPortBase
 FdHubPortBase (int fd, Notifiable *done)
 Constructor.
 
- Public Member Functions inherited from FdHubPortInterface
int fd ()
 

Private Attributes

HFlow * hub_
 Parent hub to send the data to / read the data from.
 
FdHubWriteFlow< typename HFlow::value_type > writeFlow_
 StateFlow that is performing the actual writes.
 
ReadThread readThread_
 An OSThread child that is performing the reads.
 

Friends

class ReadThread
 

Additional Inherited Members

- Static Public Member Functions inherited from FdHubPortBase
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 inherited from FdHubPortBase
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 inherited from FdHubPortBase
const char * fill_thread_name (char mode, int fd)
 Puts the desired thread name for the read or write thread.
 
void report_error ()
 Call when an IO error is encountered.
 
- Protected Member Functions inherited from FdHubPortInterface
 FdHubPortInterface (int fd)
 
- Protected Attributes inherited from FdHubPortBase
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.
 

Detailed Description

template<class HFlow>
class FdHubPort< HFlow >

HubPort that connects a raw device to a strongly typed Hub.

The device is given by the fd to an opened device instance (or socket, pipe, etc). Starts two additional threads: one for reading, one for writing.

Reads and writes will be performed in the units defined by the type of the hub: for string-typed hubs in 64 bytes units; for hubs of specific structures (such as CAN frame, dcc Packets or dcc Feedback structures) in the units of the size of the structure.

Definition at line 287 of file HubDevice.hxx.

Constructor & Destructor Documentation

◆ FdHubPort()

template<class HFlow >
FdHubPort< HFlow >::FdHubPort ( HFlow *  hub,
int  fd,
Notifiable done 
)
inline

Constructor.

Parameters
hubParent hub where to register *this.
fdfile descriptor to read/write
donewill be notified when the termination of the port is completed.

Definition at line 296 of file HubDevice.hxx.

◆ ~FdHubPort()

template<class HFlow >
FdHubPort< HFlow >::~FdHubPort ( )
inline

Definition at line 305 of file HubDevice.hxx.

Member Function Documentation

◆ unregister_write_port()

template<class HFlow >
void FdHubPort< HFlow >::unregister_write_port ( )
inlinevirtual

Removes the write flow from the hub's registration.

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

Implements FdHubPortBase.

Definition at line 310 of file HubDevice.hxx.

Friends And Related Symbol Documentation

◆ ReadThread

template<class HFlow >
friend class ReadThread
friend

Definition at line 371 of file HubDevice.hxx.

Member Data Documentation

◆ hub_

template<class HFlow >
HFlow* FdHubPort< HFlow >::hub_
private

Parent hub to send the data to / read the data from.

Definition at line 374 of file HubDevice.hxx.

◆ readThread_

template<class HFlow >
ReadThread FdHubPort< HFlow >::readThread_
private

An OSThread child that is performing the reads.

Definition at line 378 of file HubDevice.hxx.

◆ writeFlow_

template<class HFlow >
FdHubWriteFlow<typename HFlow::value_type> FdHubPort< HFlow >::writeFlow_
private

StateFlow that is performing the actual writes.

Definition at line 376 of file HubDevice.hxx.


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