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

Handler structure that ExecutorBase knows about each entry to the select call. More...

#include <Selectable.hxx>

Inheritance diagram for Selectable:
QMember StateFlowBase::StateFlowSelectHelper StateFlowBase::StateFlowTimedSelectHelper

Public Types

enum  SelectType { READ = 1 , WRITE = 2 , EXCEPT = 3 }
 Which operation this file should be selected upon. More...
 
enum  Limits { MAX_FD = (1 << 14) - 1 , MAX_PRIO = (1 << 16) - 1 }
 Helper declarations for the certain fields' maximums. More...
 

Public Member Functions

 Selectable (Executable *parent)
 Constructor.
 
void reset (SelectType type, int fd, unsigned priority)
 Re-initialize a Selectable preparing to add it to select().
 
bool is_empty ()
 
unsigned priority ()
 
SelectType type ()
 
Executableparent ()
 
int fd ()
 
void set_wakeup (Executable *e)
 Can be used to override the executable to wake up.
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Private Attributes

unsigned selectType_: 2
 What to watch the file for. See SelectType.
 
unsigned fd_: 14
 File descriptor to watch.
 
unsigned priority_: 16
 When the select condition is met, the Executable will be scheduled at this priority.
 
Executablewakeup_
 This executable will be scheduled on the executor when the select condition is met.
 

Friends

class ExecutorBase
 

Additional Inherited Members

- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

Handler structure that ExecutorBase knows about each entry to the select call.

See ExecutorBase::select().

Definition at line 40 of file Selectable.hxx.

Member Enumeration Documentation

◆ Limits

Helper declarations for the certain fields' maximums.

Enumerator
MAX_FD 

Largest FD we accept (otherwise crash with error).

MAX_PRIO 

Largest priority we accept (otherwise we clip).

Definition at line 53 of file Selectable.hxx.

◆ SelectType

Which operation this file should be selected upon.

(i.e. which fd_set the given fd is coming in).

Definition at line 45 of file Selectable.hxx.

Constructor & Destructor Documentation

◆ Selectable()

Selectable::Selectable ( Executable parent)
inline

Constructor.

Parameters
parentis the executable that will be woken up when this selectable is triggered.

Definition at line 63 of file Selectable.hxx.

Member Function Documentation

◆ fd()

int Selectable::fd ( )
inline
Returns
Filedes to wait for.

Definition at line 106 of file Selectable.hxx.

◆ is_empty()

bool Selectable::is_empty ( )
inline
Returns
true if this selectable was never used before.

Definition at line 82 of file Selectable.hxx.

◆ parent()

Executable * Selectable::parent ( )
inline
Returns
Executable to enqueue upon successful triggering.

Definition at line 100 of file Selectable.hxx.

◆ priority()

unsigned Selectable::priority ( )
inline
Returns
priority upon which the executable should be enqueued upon trigger.

Definition at line 88 of file Selectable.hxx.

◆ reset()

void Selectable::reset ( SelectType  type,
int  fd,
unsigned  priority 
)
inline

Re-initialize a Selectable preparing to add it to select().

Parameters
typewhether we waiting for READ, WRITE or EXCEPT.
fdfile descriptor to wait for.
prioritywhat priority should the callback be executed at once the file triggers.

Definition at line 73 of file Selectable.hxx.

◆ set_wakeup()

void Selectable::set_wakeup ( Executable e)
inline

Can be used to override the executable to wake up.

Make sure to set it back afterwards.

Parameters
eis the new executable to trigger.

Definition at line 113 of file Selectable.hxx.

◆ type()

SelectType Selectable::type ( )
inline
Returns
what we should select this upon, READ, WRITE or EXCEPT.

Definition at line 94 of file Selectable.hxx.

Friends And Related Symbol Documentation

◆ ExecutorBase

friend class ExecutorBase
friend

Definition at line 119 of file Selectable.hxx.

Member Data Documentation

◆ fd_

unsigned Selectable::fd_
private

File descriptor to watch.

Definition at line 124 of file Selectable.hxx.

◆ priority_

unsigned Selectable::priority_
private

When the select condition is met, the Executable will be scheduled at this priority.

Definition at line 127 of file Selectable.hxx.

◆ selectType_

unsigned Selectable::selectType_
private

What to watch the file for. See SelectType.

Definition at line 122 of file Selectable.hxx.

◆ wakeup_

Executable* Selectable::wakeup_
private

This executable will be scheduled on the executor when the select condition is met.

Definition at line 130 of file Selectable.hxx.


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