ARPDAS_QNX6 1.0
|
#include <Selector.h>
Public Member Functions | |
Selector () | |
~Selector () | |
void | add_child (Selectee *P) |
void | delete_child (int fd_in) |
int | update_flags (int fd_in, int flag) |
void | set_gflag (unsigned gflag_index) |
void | event_loop () |
Static Public Member Functions | |
static int | gflag (unsigned gflag_index) |
Static Public Attributes | |
static const int | Sel_Read = 1 |
static const int | Sel_Write = 2 |
static const int | Sel_Except = 4 |
static const int | Sel_Timeout = 8 |
Private Member Functions | |
virtual int | ProcessTimeout () |
virtual Timeout * | GetTimeout () |
Private Attributes | |
SelecteeMap | S |
bool | children_changed |
int | gflags |
Definition at line 31 of file Selector.h.
Selector::Selector | ( | ) |
Definition at line 7 of file Selector.cc.
References children_changed, and gflags.
Selector::~Selector | ( | ) |
Actually does nothing.
Definition at line 15 of file Selector.cc.
void Selector::add_child | ( | Selectee * | P | ) |
Adds the Selectee as a child of the Selector. This adds the Selectee's fd to the list of fds in the Selector's select() call, depending on the Selectee's flags.
Definition at line 23 of file Selector.cc.
References children_changed, Selectee::fd, nl_error, S, and Selectee::Stor.
void Selector::delete_child | ( | int | fd_in | ) |
Removes Selectee from the Selector and deletes the Selectee. Note that this is for use in a special case where the fd is being closed and the child needs to be deleted, but the caller does not know the mapping from the fd to the Selectee. In the usual case, the Selectee is deleted by its owner after the event_loop has exited, and it is unnecessary to explicitly remove the Selectees as children of the Selector.
Definition at line 41 of file Selector.cc.
References children_changed, Selectee::fd, nl_assert, nl_error, and S.
void Selector::event_loop | ( | ) |
Loops waiting on select(), using the fds and flags of each Selectee registered via add_child(). When select() indicates that an fd is ready, the corresponding Selectee's ProcessData() method is invoked with the flag value indicating what action is ready.
Definition at line 93 of file Selector.cc.
References children_changed, Selectee::fd, Selectee::flags, Selectee::GetTimeout(), GetTimeout(), gflags, nl_error, Selectee::ProcessData(), ProcessTimeout(), S, Sel_Except, Sel_Read, Sel_Timeout, Sel_Write, TimeoutAccumulator::Set_Min(), and TimeoutAccumulator::timeout_val().
Timeout * Selector::GetTimeout | ( | ) | [private, virtual] |
Virtual method to allow Selector to bid on the select() timeout along with the Selectee children. The minimum timeout value is used.
Definition at line 167 of file Selector.cc.
Referenced by event_loop().
static int Selector::gflag | ( | unsigned | gflag_index | ) | [inline, static] |
Method to map a global flag number to a bit mask to be set in a Selectee's flags word.
gflag_index | global flag bit number |
Definition at line 49 of file Selector.h.
Referenced by set_gflag().
int Selector::ProcessTimeout | ( | ) | [private, virtual] |
Virtual method called whenever select() returns 0. The default does nothing, but it can be overridden.
Definition at line 160 of file Selector.cc.
Referenced by event_loop().
void Selector::set_gflag | ( | unsigned | gflag_index | ) |
Sets a bit in the global flags word. Selectees can set a corresponding bit in their flags word to request notification when the bit gets set. The function Selector::gflag(gflag_index) returns the bit that corresponds to set_gflag(gflag_index). gflag_index can take on values from 0 to 8*sizeof(int)-4.
Definition at line 81 of file Selector.cc.
References gflag(), gflags, and nl_assert.
Referenced by TM_Selectee::ProcessData().
int Selector::update_flags | ( | int | fd_in, |
int | flag | ||
) |
Useful when we know the fd but not the Selectee.
Definition at line 60 of file Selector.cc.
References children_changed, Selectee::flags, and S.
bool Selector::children_changed [private] |
Definition at line 55 of file Selector.h.
Referenced by add_child(), delete_child(), event_loop(), Selector(), and update_flags().
int Selector::gflags [private] |
Definition at line 56 of file Selector.h.
Referenced by event_loop(), Selector(), and set_gflag().
SelecteeMap Selector::S [private] |
Definition at line 54 of file Selector.h.
Referenced by add_child(), delete_child(), event_loop(), and update_flags().
const int Selector::Sel_Except = 4 [static] |
Definition at line 35 of file Selector.h.
Referenced by event_loop().
const int Selector::Sel_Read = 1 [static] |
Definition at line 33 of file Selector.h.
Referenced by event_loop(), and Ser_Sel::init().
const int Selector::Sel_Timeout = 8 [static] |
Definition at line 36 of file Selector.h.
Referenced by event_loop().
const int Selector::Sel_Write = 2 [static] |
Definition at line 34 of file Selector.h.
Referenced by event_loop(), and TM_Selectee::init().