xrootd
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
XrdSys::IOEvents::Poller Class Referenceabstract

#include <XrdSysIOEvents.hh>

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

Classes

struct  PipeData
 

Public Types

enum  CreateOpts { optTOM }
 

Public Member Functions

void Stop ()
 
 Poller (int cFD, int rFD)
 
virtual ~Poller ()
 Destructor. Stop() is effecively called when this object is deleted.
 

Static Public Member Functions

static PollerCreate (int &eNum, const char **eTxt=0, int crOpts=0)
 

Protected Member Functions

void CbkTMO ()
 
bool CbkXeq (Channel *cP, int events, int eNum, const char *eTxt)
 
int GetFault (Channel *cP)
 
int GetPollEnt (Channel *cP)
 
int GetRequest ()
 
bool Init (Channel *cP, int &eNum, const char **eTxt, bool &isLockd)
 
void LockChannel (Channel *cP)
 
int Poll2Enum (short events)
 
int SendCmd (PipeData &cmd)
 
void SetPollEnt (Channel *cP, int ptEnt)
 
bool TmoAdd (Channel *cP, int tmoSet)
 
void TmoDel (Channel *cP)
 
int TmoGet ()
 
void UnLockChannel (Channel *cP)
 
virtual void Begin (XrdSysSemaphore *syncp, int &rc, const char **eTxt)=0
 
virtual void Exclude (Channel *cP, bool &isLocked, bool dover=1)=0
 
virtual bool Include (Channel *cP, int &eNum, const char **eTxt, bool &isLocked)=0
 
virtual bool Modify (Channel *cP, int &eNum, const char **eTxt, bool &isLocked)=0
 
virtual void Shutdown ()=0
 
 CPP_ATOMIC_TYPE (bool) wakePend
 

Protected Attributes

ChannelattBase
 
ChanneltmoBase
 
pthread_t pollTid
 
struct pollfd pipePoll
 
int cmdFD
 
int reqFD
 
PipeData reqBuff
 
char * pipeBuff
 
int pipeBlen
 
unsigned char tmoMask
 
bool chDead
 

Static Protected Attributes

static time_t maxTime
 
static pid_t parentPID
 

Private Member Functions

void Attach (Channel *cP)
 
void Detach (Channel *cP, bool &isLocked, bool keep=true)
 
void WakeUp ()
 

Static Private Member Functions

static PollernewPoller (int pFD[2], int &eNum, const char **eTxt)
 

Private Attributes

XrdSysMutex adMutex
 
XrdSysMutex toMutex
 

Friends

class BootStrap
 
class Channel
 

Detailed Description

Define a poller object interface. A poller fields and dispatches event callbacks. An actual instance of a poller object is obtained by using the Create() method. You cannot simply create an instance of this object using new or in-place declaration since it is abstract. Any number of these objects may created. Each creation spawns a polling thread.

Member Enumeration Documentation

◆ CreateOpts

Create a specialized instance of a poller object, initialize it, and start the polling process. You must call Create() to obtain a specialized poller.

Parameters
eNumPlace where errno is placed upon failure.
eTxtPlace where a pointer to the description of the failing operation is to be set. If null, no description is returned.
crOptsPoller options (see static const optxxx): optTOM - Timeout resumption after a timeout event must be manually reenabled. By default, event timeouts are automatically renabled after successful callbacks.
Returns
!0 Poller successfully created and started. eNum contains zero. eTxt if not null contains a null string. The returned value is a pointer to the Poller object. 0 Poller could not be created. eNum contains the associated errno value. eTxt if not null contains the failing operation.
Enumerator
optTOM 

Constructor & Destructor Documentation

◆ Poller()

XrdSys::IOEvents::Poller::Poller ( int  cFD,
int  rFD 
)

Constructor

Parameters
cFDThe file descriptor to send commands to the poll thread.
rFDThe file descriptor to recv commands in the poll thread.

◆ ~Poller()

virtual XrdSys::IOEvents::Poller::~Poller ( )
inlinevirtual

Destructor. Stop() is effecively called when this object is deleted.

Member Function Documentation

◆ Attach()

void XrdSys::IOEvents::Poller::Attach ( Channel cP)
private

◆ Begin()

virtual void XrdSys::IOEvents::Poller::Begin ( XrdSysSemaphore syncp,
int &  rc,
const char **  eTxt 
)
protectedpure virtual

Start the polling event loop. An implementation must be supplied. Begin() is called via the internal BootStrap class from a new thread.

◆ CbkTMO()

void XrdSys::IOEvents::Poller::CbkTMO ( )
protected

◆ CbkXeq()

bool XrdSys::IOEvents::Poller::CbkXeq ( Channel cP,
int  events,
int  eNum,
const char *  eTxt 
)
protected

◆ CPP_ATOMIC_TYPE()

XrdSys::IOEvents::Poller::CPP_ATOMIC_TYPE ( bool  )
protected

◆ Create()

static Poller * XrdSys::IOEvents::Poller::Create ( int &  eNum,
const char **  eTxt = 0,
int  crOpts = 0 
)
static

◆ Detach()

void XrdSys::IOEvents::Poller::Detach ( Channel cP,
bool &  isLocked,
bool  keep = true 
)
private

◆ Exclude()

virtual void XrdSys::IOEvents::Poller::Exclude ( Channel cP,
bool &  isLocked,
bool  dover = 1 
)
protectedpure virtual

Remove a channel to the poll set. An implementation must be supplied. The channel is locked when this method is called but must be unlocked by the method if a command is sent to the poller thread and isLocked set to false.

◆ GetFault()

int XrdSys::IOEvents::Poller::GetFault ( Channel cP)
inlineprotected

◆ GetPollEnt()

int XrdSys::IOEvents::Poller::GetPollEnt ( Channel cP)
inlineprotected

◆ GetRequest()

int XrdSys::IOEvents::Poller::GetRequest ( )
protected

◆ Include()

virtual bool XrdSys::IOEvents::Poller::Include ( Channel cP,
int &  eNum,
const char **  eTxt,
bool &  isLocked 
)
protectedpure virtual

Add a channel to the poll set. An implementation must be supplied. The channel is locked when this method is called but must be unlocked by the method if a command is sent to the poller thread and isLocked set to false.

◆ Init()

bool XrdSys::IOEvents::Poller::Init ( Channel cP,
int &  eNum,
const char **  eTxt,
bool &  isLockd 
)
protected

◆ LockChannel()

void XrdSys::IOEvents::Poller::LockChannel ( Channel cP)
inlineprotected

◆ Modify()

virtual bool XrdSys::IOEvents::Poller::Modify ( Channel cP,
int &  eNum,
const char **  eTxt,
bool &  isLocked 
)
protectedpure virtual

Modify the event status of a channel. An implementation must be supplied. The channel is locked when this method is called but must be unlocked by the method if a command is sent to the poller thread and isLocked set to false.

◆ newPoller()

static Poller * XrdSys::IOEvents::Poller::newPoller ( int  pFD[2],
int &  eNum,
const char **  eTxt 
)
staticprivate

◆ Poll2Enum()

int XrdSys::IOEvents::Poller::Poll2Enum ( short  events)
protected

◆ SendCmd()

int XrdSys::IOEvents::Poller::SendCmd ( PipeData cmd)
protected

◆ SetPollEnt()

void XrdSys::IOEvents::Poller::SetPollEnt ( Channel cP,
int  ptEnt 
)
protected

◆ Shutdown()

virtual void XrdSys::IOEvents::Poller::Shutdown ( )
protectedpure virtual

Shutdown the poller. An implementation must be supplied. The shutdown method must release any allocated storage and close private file descriptors. The polling thread will have already been terminated and x-thread pipe closed. Warning: the derived destructor must call Stop() and do nothing else!

◆ Stop()

void XrdSys::IOEvents::Poller::Stop ( )

Stop a poller object. Active callbacks are completed. Pending callbacks are discarded. After which the poller event thread exits. Subsequently, each associated channel is disabled and removed from the poller object. If the channel is enabled for a StopEvent, the stop callback is invoked. However, any attempt to use the channel methods that require an active poller will return an error.

Since a stopped poller cannot be restarted; the only thing left is to delete it. This also applies to all the associated channels since they no longer have an active poller.

◆ TmoAdd()

bool XrdSys::IOEvents::Poller::TmoAdd ( Channel cP,
int  tmoSet 
)
protected

◆ TmoDel()

void XrdSys::IOEvents::Poller::TmoDel ( Channel cP)
protected

◆ TmoGet()

int XrdSys::IOEvents::Poller::TmoGet ( )
protected

◆ UnLockChannel()

void XrdSys::IOEvents::Poller::UnLockChannel ( Channel cP)
inlineprotected

◆ WakeUp()

void XrdSys::IOEvents::Poller::WakeUp ( )
private

Friends And Related Symbol Documentation

◆ BootStrap

friend class BootStrap
friend

◆ Channel

friend class Channel
friend

Member Data Documentation

◆ adMutex

XrdSysMutex XrdSys::IOEvents::Poller::adMutex
private

◆ attBase

Channel* XrdSys::IOEvents::Poller::attBase
protected

◆ chDead

bool XrdSys::IOEvents::Poller::chDead
protected

◆ cmdFD

int XrdSys::IOEvents::Poller::cmdFD
protected

◆ maxTime

time_t XrdSys::IOEvents::Poller::maxTime
staticprotected

◆ parentPID

pid_t XrdSys::IOEvents::Poller::parentPID
staticprotected

◆ pipeBlen

int XrdSys::IOEvents::Poller::pipeBlen
protected

◆ pipeBuff

char* XrdSys::IOEvents::Poller::pipeBuff
protected

◆ pipePoll

struct pollfd XrdSys::IOEvents::Poller::pipePoll
protected

◆ pollTid

pthread_t XrdSys::IOEvents::Poller::pollTid
protected

◆ reqBuff

PipeData XrdSys::IOEvents::Poller::reqBuff
protected

◆ reqFD

int XrdSys::IOEvents::Poller::reqFD
protected

◆ tmoBase

Channel* XrdSys::IOEvents::Poller::tmoBase
protected

◆ tmoMask

unsigned char XrdSys::IOEvents::Poller::tmoMask
protected

◆ toMutex

XrdSysMutex XrdSys::IOEvents::Poller::toMutex
private

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