NL_Multiplexor
NL_Multiplexor
nl
1998 12-06
CLASS
NL_Multiplexor - an NL_Channel multiplexor
SYNOPSIS
NL_Multiplexor is used to multiplex input/output on NL_Channel
objects. NL_Multiplexor is built on two linked lists of
NL_ChannelNode objects
(checklist and readylist). Checklist is the list of channels that the
multiplexor will check for possible activity. Readylist is the list
of channels that were ready as of the last call to Wait().
NL_ChannelNode contains a pointer to an
actual NL_Channel and flags that determine
what the channel will be checked for if in the checklist.
If the NL_ChannelNode is part of readylist then the
flag setting corresponding to the channels condition is set.
There are three possible bitwise
flag settings as follows:
| NL_READ |
Ready for reading.
|
| NL_WRITE |
Ready for writing.
|
| NL_EXCEPTION |
An exceptional condition on the channel.
|
CONSTRUCTOR
NL_Multiplexor()
Construct a multiplexor. The checklist and readylist are constructed as well
and may be accessed through the appropriate accessor member functions.
MEMBER FUNCTIONS
long Wait()
Wait for the period of time specified by SetTimeout()
for a channel to be ready as specified by the checklist.
An NL_ChannelNode is added to the readylist for each channel in checklist
meeting the conditions specified.
Returns the number of NL_ChannelNodes in the readylist. Therefore, if 0
is returned the multiplexor timed out.
long SetTimeout(long msecs)
Set the timeout length for Wait() in milliseconds. The default timeout is 0.
The timeout may be set to NL_MULTIPLEXOR_BLOCK which will cause the multiplexor
to have an infinite timeout.
Returns TRUE.
long GetTimeout()
Return the current timeout setting.
NL_ChannelList *GetChecklist()
Return the checklist.
NL_ChannelList *GetReadylist()
Return the readylist.
void AddToChecklist(NL_Channel *channel, long flags)
Convienience function which will create a NL_ChannelNode for
channel with flags and then add it to the checklist.