XrdSys::IOEvents::Channel Class Reference

#include <XrdSysIOEvents.hh>

Collaboration diagram for XrdSys::IOEvents::Channel:
Collaboration graph
[legend]

List of all members.

Classes

struct  dlQ

Public Types

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

void Delete ()
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)

Private Types

enum  Status { isClear = 0, isCBMode, isDead }

Private Member Functions

 ~Channel ()
 Destuctor is private, use Delete() to delete this object.
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

Member Enumeration Documentation

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.

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 (  )  [inline, private]

Destuctor is private, use Delete() to delete this object.


Member Function Documentation

void XrdSys::IOEvents::Channel::Delete (  ) 

Delete a channel. You must use this method instead of delete. The Delete() may block if an channel is being deleted outside of the poller thread. When this object is deleted, all events are disabled, pending callbacks are either completed or canceled, and the channel is removed from the assigned poller. Only then is the storage freed.

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.
cbArg 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.

References chEvents, and chPoller.

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.

References chFD.

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

Referenced by GetEvents().

Referenced by GetFD().

Referenced by GetEvents().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 8 May 2020 for xrootd by  doxygen 1.6.1