![]() |
XRootD
|
#include <XrdSysIOEvents.hh>
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 | |
Channel (Poller *pollP, int fd, CallBack *cbP=0, void *cbArg=0) | |
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) |
Friends | |
class | Poller |
Definition at line 173 of file XrdSysIOEvents.hh.
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. |
Definition at line 192 of file XrdSysIOEvents.hh.
Constructor.
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 deferred setting it here. |
cbArg | The argument to be passed to the callback object. |
Definition at line 285 of file XrdSysIOEvents.cc.
References XrdSys::IOEvents::pollInit.
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.
Definition at line 303 of file XrdSysIOEvents.cc.
References XrdSys::IOEvents::Poller::chDead, Xrd::dec, Xrd::hex, XrdSysThread::ID(), IF_TRACE, XrdSys::IOEvents::pollErr1, XrdSys::IOEvents::Poller::pollTid, XrdSysThread::Same(), STATUS, and XrdSysSemaphore::Wait().
bool XrdSys::IOEvents::Channel::Disable | ( | int | events, |
const char ** | eText = 0 |
||
) |
Disable one or more events. Ignored for already disabled events.
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). |
Definition at line 356 of file XrdSysIOEvents.cc.
References IF_TRACE, XrdSys::IOEvents::pollWait, TRACE_MOD, and TRACE_NOD.
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.
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). |
Definition at line 401 of file XrdSysIOEvents.cc.
References CPP_ATOMIC_LOAD, IF_TRACE, XrdSys::IOEvents::Poller::maxTime, XrdSys::IOEvents::pollErr1, XrdSys::IOEvents::pollWait, XrdSys::IOEvents::CallBack::ReadyToRead, XrdSys::IOEvents::CallBack::ReadyToWrite, REVENTS, TRACE_MOD, TRACE_NOD, and WEVENTS.
Referenced by XrdCl::PollerBuiltIn::Start().
void XrdSys::IOEvents::Channel::GetCallBack | ( | CallBack ** | cbP, |
void ** | cbArg | ||
) |
Get the callback object and argument associated with this channel.
cbP | Place where the pointer is to be returned. |
cbArg | Place where the callback argument is to be returned. |
Definition at line 480 of file XrdSysIOEvents.cc.
|
inline |
Get the events that are currently enabled for this channel.
Definition at line 267 of file XrdSysIOEvents.hh.
Referenced by XrdSys::IOEvents::PollE::Include(), XrdSys::IOEvents::PollPoll::Include(), XrdSys::IOEvents::PollPort::Include(), XrdSys::IOEvents::PollE::Modify(), XrdSys::IOEvents::PollKQ::Modify(), XrdSys::IOEvents::PollPoll::Modify(), and XrdSys::IOEvents::PollPort::Modify().
|
inline |
Get the file descriptor number associated with this channel.
Definition at line 276 of file XrdSysIOEvents.hh.
Referenced by XrdSys::IOEvents::PollE::Exclude(), XrdSys::IOEvents::PollKQ::Exclude(), XrdSys::IOEvents::PollPoll::Exclude(), XrdSys::IOEvents::PollPort::Exclude(), XrdSys::IOEvents::PollE::Include(), XrdSys::IOEvents::PollPoll::Include(), XrdSys::IOEvents::PollPort::Include(), XrdSys::IOEvents::PollerInit::Modify(), XrdSys::IOEvents::PollE::Modify(), XrdSys::IOEvents::PollKQ::Modify(), XrdSys::IOEvents::PollPoll::Modify(), and XrdSys::IOEvents::PollPort::Modify().
void XrdSys::IOEvents::Channel::SetCallBack | ( | CallBack * | cbP, |
void * | cbArg = 0 |
||
) |
Set the callback object and argument associated with this channel.
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. |
Definition at line 513 of file XrdSysIOEvents.cc.
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.
fd | The associated file descriptor number. |
Definition at line 531 of file XrdSysIOEvents.cc.
References XrdSys::IOEvents::pollInit, and XrdSys::IOEvents::pollWait.
|
friend |
Definition at line 175 of file XrdSysIOEvents.hh.