XrdSys::IOEvents::Channel Class Reference

#include <XrdSysIOEvents.hh>

Collaboration diagram for XrdSys::IOEvents::Channel:

Collaboration graph
[legend]
List of all members.

Public Types

 readEvents = 0x01
 Read and Read Timeouts.
 writeEvents = 0x04
 Write and Write Timeouts.
 rwEvents = 0x05
 Both of the above.
 errorEvents = 0x10
 Error event non-r/w specific.
 stopEvent = 0x20
 Poller stop event.
 allEvents = 0x35
 All of the above.
enum  EventCode {
  readEvents = 0x01, writeEvents = 0x04, rwEvents = 0x05, errorEvents = 0x10,
  stopEvent = 0x20, allEvents = 0x35
}
 Event bits used to feed Enable() and Disable(); can be or'd. More...

Public Member Functions

bool Disable (int events, const char **eText=0)
bool Enable (int events, int timeout=0, const char **eText=0)
void GetCallBack (CallBack **cbP, void **cbArg)
int GetEvents ()
int GetFD ()
void SetCallBack (CallBack *cbP, void *cbArg=0)
void SetFD (int fd)
 Channel (Poller *pollP, int fd, CallBack *cbP=0, void *cbArg=0)
 ~Channel ()

Private Types

 isClear = 0
 isCBMode
 isDead
enum  Status { isClear = 0, isCBMode, isDead }

Private Member Functions

void Reset (Poller *thePoller, int fd, int eNum=0)

Private Attributes

XrdSysRecMutex chMutex
dlQ attList
dlQ tmoList
PollerchPoller
PollerchPollXQ
CallBackchCB
void * chCBA
int chFD
int pollEnt
int chRTO
int chWTO
time_t rdDL
time_t wrDL
time_t deadLine
char dlType
char chEvents
char chStat
char inTOQ
char inPSet
char reMod
short chFault

Friends

class Poller

Classes

struct  dlQ

Member Enumeration Documentation

enum XrdSys::IOEvents::Channel::EventCode

Event bits used to feed Enable() and Disable(); can be or'd.

Enumerator:
readEvents  Read and Read Timeouts.
writeEvents  Write and Write Timeouts.
rwEvents  Both of the above.
errorEvents  Error event non-r/w specific.
stopEvent  Poller stop event.
allEvents  All of the above.

enum XrdSys::IOEvents::Channel::Status [private]

Enumerator:
isClear 
isCBMode 
isDead 


Constructor & Destructor Documentation

XrdSys::IOEvents::Channel::Channel ( Poller pollP,
int  fd,
CallBack cbP = 0,
void *  cbArg = 0 
)

Constructor.

Parameters:
pollP Pointer to the poller object to which this channel will be assigned. Events are initially disabled after assignment and no timeout applies. Poller object assignment is permanent for the life of the channel object.
fd The associated file descriptor number. It should not be assigned to any other channel and must be valid when the channel is enabled. Use SetFD() to set a new value.
cbP Pointer to the callback object (see above). The callback object must not be deleted while associated to a channel. A callback object must exist in order for the channel to be enabled. Use SetCallBack() if you defered setting it here.
cbArg The argument to be passed to the callback object.

XrdSys::IOEvents::Channel::~Channel (  ) 

Destuctor. When this object is deleted, all events are disabled, pending callbacks are completed, and the channel is removed from the assigned poller. Only then is the storage freed.


Member Function Documentation

bool XrdSys::IOEvents::Channel::Disable ( int  events,
const char **  eText = 0 
)

Disable one or more events. Ignored for already disabled events.

Parameters:
events one or more events or'd together (see EventCode above).
eText optional pointer to where an operation description is to be placed when an error occurs (i.e. returns false).
Returns:
true Events successfully disabled. false Events not disabled; errno holds the error number and if eText is supplied, points to the operation desscription.

bool XrdSys::IOEvents::Channel::Enable ( int  events,
int  timeout = 0,
const char **  eText = 0 
)

Enable one or more events. Events that are already enabled remain enabled but may have their timeout value change.

Enable can fail for many reasons. Most importantly, if the channel was disabled for all events when a fatal error occurred; enabling it immediately returns the fatal error without invoking the callback. This happens on platforms that disallow physically masking out error events.

Additionally, when an error occurs and the channel is not enabled for error events but is enabled for read or write, the callback is called indicating ReadyToRead or ReadyToWrite. A subsequent write will then end with an error (typically, EPIPE) and a subsequent read will end with an erorr or indicate zero bytes read; either of which should be treated as an error (typically, POLLHUP). Generally, you should always allow separable error events.

Parameters:
events one or more events or'd together (see EventCode above).
timeout >0 maximum seconds that may elapsed before a timeout event corresponding to the specified event(s) occurs. =0 Keep whatever timeout is currently in effect from the previous Enable() invocation for the event(s). <0 No timeout applies. There can be separate timeouts for read and write if Enable() is separately called for each event code. Otherwise, the timeout applies to all specified events. The timeout is ignored for error events.
eText optional pointer to where an operation description is to be placed when an error occurs (i.e. returns false).
Returns:
true Events successfully enabled. false Events not enabled; errno holds the error number and if eText is supplied, points to the operation desscription.

void XrdSys::IOEvents::Channel::GetCallBack ( CallBack **  cbP,
void **  cbArg 
)

Get the callback object and argument associated with this channel.

Parameters:
cbP Place where the pointer is to be returned.
caP Place where the callback argument is to be returned.

int XrdSys::IOEvents::Channel::GetEvents (  )  [inline]

Get the events that are currently enabled for this channel.

Returns:
>0 Event bits that are enabled (see EventCode above). =0 No events are enabled. <0 Channel not assigned to a Poller object.

int XrdSys::IOEvents::Channel::GetFD (  )  [inline]

Get the file descriptor number associated with this channel.

Returns:
>=0 The file descriptor number. < 0 No file desciptor associated with the channel.

void XrdSys::IOEvents::Channel::Reset ( Poller thePoller,
int  fd,
int  eNum = 0 
) [private]

void XrdSys::IOEvents::Channel::SetCallBack ( CallBack cbP,
void *  cbArg = 0 
)

Set the callback object and argument associated with this channel.

Parameters:
cbP Pointer to the callback object (see above). The callback object must not be deleted while associated to a channel. A null callback object pointer effectively disables the channel.
cbArg The argument to be passed to the callback object.

void XrdSys::IOEvents::Channel::SetFD ( int  fd  ) 

Set a new file descriptor to be associated with this channel. The channel is removed from polling consideration but remains attached to the poller. The new file descriptor is recorded but the channel remains disabled. You must use Enable() to add the file descriptor back to the polling set. This allows you to retract a file descriptor about to be closed without having a new file descriptor handy (e.g., use -1). This facilitates channel re-use.

Parameters:
fd The associated file descriptor number.


Friends And Related Function Documentation

friend class Poller [friend]


Member Data Documentation

dlQ XrdSys::IOEvents::Channel::attList [private]

CallBack* XrdSys::IOEvents::Channel::chCB [private]

void* XrdSys::IOEvents::Channel::chCBA [private]

char XrdSys::IOEvents::Channel::chEvents [private]

short XrdSys::IOEvents::Channel::chFault [private]

int XrdSys::IOEvents::Channel::chFD [private]

XrdSysRecMutex XrdSys::IOEvents::Channel::chMutex [private]

Poller* XrdSys::IOEvents::Channel::chPoller [private]

Poller* XrdSys::IOEvents::Channel::chPollXQ [private]

int XrdSys::IOEvents::Channel::chRTO [private]

char XrdSys::IOEvents::Channel::chStat [private]

int XrdSys::IOEvents::Channel::chWTO [private]

time_t XrdSys::IOEvents::Channel::deadLine [private]

char XrdSys::IOEvents::Channel::dlType [private]

char XrdSys::IOEvents::Channel::inPSet [private]

char XrdSys::IOEvents::Channel::inTOQ [private]

int XrdSys::IOEvents::Channel::pollEnt [private]

time_t XrdSys::IOEvents::Channel::rdDL [private]

char XrdSys::IOEvents::Channel::reMod [private]

dlQ XrdSys::IOEvents::Channel::tmoList [private]

time_t XrdSys::IOEvents::Channel::wrDL [private]


The documentation for this class was generated from the following file:
Generated on 16 Jan 2014 for xrootd by  doxygen 1.4.7