xrootd
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
XrdSys::IOEvents::Channel Class Reference

#include <XrdSysIOEvents.hh>

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

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

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

◆ Status

Enumerator
isClear 
isCBMode 
isDead 

Constructor & Destructor Documentation

◆ Channel()

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

Constructor.

Parameters
pollPPointer 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.
fdThe 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.
cbPPointer 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 deferred setting it here.
cbArgThe argument to be passed to the callback object.

◆ ~Channel()

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

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

Member Function Documentation

◆ Delete()

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.

◆ Disable()

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

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

Parameters
eventsone or more events or'd together (see EventCode above).
eTextoptional 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.

◆ Enable()

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
eventsone 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.
eTextoptional 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.

◆ GetCallBack()

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

Get the callback object and argument associated with this channel.

Parameters
cbPPlace where the pointer is to be returned.
cbArgPlace where the callback argument is to be returned.

◆ GetEvents()

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.

◆ GetFD()

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.

◆ Reset()

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

◆ SetCallBack()

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

Set the callback object and argument associated with this channel.

Parameters
cbPPointer 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.
cbArgThe argument to be passed to the callback object.

◆ SetFD()

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
fdThe associated file descriptor number.

Friends And Related Symbol Documentation

◆ Poller

friend class Poller
friend

Member Data Documentation

◆ attList

dlQ XrdSys::IOEvents::Channel::attList
private

◆ chCB

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

◆ chCBA

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

◆ chEvents

char XrdSys::IOEvents::Channel::chEvents
private

Referenced by GetEvents().

◆ chFault

short XrdSys::IOEvents::Channel::chFault
private

◆ chFD

int XrdSys::IOEvents::Channel::chFD
private

Referenced by GetFD().

◆ chMutex

XrdSysRecMutex XrdSys::IOEvents::Channel::chMutex
private

◆ chPoller

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

Referenced by GetEvents().

◆ chPollXQ

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

◆ chRTO

int XrdSys::IOEvents::Channel::chRTO
private

◆ chStat

char XrdSys::IOEvents::Channel::chStat
private

◆ chWTO

int XrdSys::IOEvents::Channel::chWTO
private

◆ deadLine

time_t XrdSys::IOEvents::Channel::deadLine
private

◆ dlType

char XrdSys::IOEvents::Channel::dlType
private

◆ inPSet

char XrdSys::IOEvents::Channel::inPSet
private

◆ inTOQ

char XrdSys::IOEvents::Channel::inTOQ
private

◆ pollEnt

int XrdSys::IOEvents::Channel::pollEnt
private

◆ rdDL

time_t XrdSys::IOEvents::Channel::rdDL
private

◆ reMod

char XrdSys::IOEvents::Channel::reMod
private

◆ tmoList

dlQ XrdSys::IOEvents::Channel::tmoList
private

◆ wrDL

time_t XrdSys::IOEvents::Channel::wrDL
private

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