A poller implementation using the build-in XRootD poller.
More...
#include <XrdClPollerBuiltIn.hh>
A poller implementation using the build-in XRootD poller.
Definition at line 40 of file XrdClPollerBuiltIn.hh.
◆ PollerBuiltIn()
XrdCl::PollerBuiltIn::PollerBuiltIn |
( |
| ) |
|
|
inline |
◆ ~PollerBuiltIn()
XrdCl::PollerBuiltIn::~PollerBuiltIn |
( |
| ) |
|
|
inline |
◆ AddSocket()
Add socket to the polling loop
- Parameters
-
socket | the socket |
handler | object handling the events |
Implements XrdCl::Poller.
Definition at line 253 of file XrdClPollerBuiltIn.cc.
268 log->
Error(
PollerMsg,
"Socket is not in a state valid for polling" );
272 log->
Debug(
PollerMsg,
"Adding socket %p to the poller", socket );
277 SocketMap::const_iterator it = pSocketMap.find( socket );
278 if( it != pSocketMap.end() )
290 PollerHelper *helper =
new PollerHelper();
291 helper->callBack = new ::SocketCallBack( socket, handler );
301 pSocketMap[socket] = helper;
static Log * GetLog()
Get default log.
void Error(uint64_t topic, const char *format,...)
Report an error.
void Warning(uint64_t topic, const char *format,...)
Report a warning.
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
virtual void Initialize(Poller *)
Initializer.
std::string GetName() const
Get the string representation of the socket.
@ Connected
The socket is connected.
@ Connecting
The connection process is in progress.
int GetFD()
Get the file descriptor.
SocketStatus GetStatus() const
Get the socket status.
References XrdCl::Socket::Connected, XrdCl::Socket::Connecting, XrdCl::Log::Debug(), XrdCl::Log::Error(), XrdCl::Socket::GetFD(), XrdCl::DefaultEnv::GetLog(), XrdCl::Socket::GetName(), XrdCl::Socket::GetStatus(), XrdCl::SocketHandler::Initialize(), XrdCl::PollerMsg, and XrdCl::Log::Warning().
◆ EnableReadNotification()
bool XrdCl::PollerBuiltIn::EnableReadNotification |
( |
Socket * |
socket, |
|
|
bool |
notify, |
|
|
uint16_t |
timeout = 60 |
|
) |
| |
|
virtual |
Notify the handler about read events
- Parameters
-
socket | the socket |
notify | specify if the handler should be notified |
timeout | if no read event occurred after this time a timeout event will be generated |
Implements XrdCl::Poller.
Definition at line 354 of file XrdClPollerBuiltIn.cc.
363 log->
Error(
PollerMsg,
"Invalid socket, read events unavailable" );
371 SocketMap::const_iterator it = pSocketMap.find( socket );
372 if( it == pSocketMap.end() )
379 PollerHelper *helper = (PollerHelper*)it->second;
387 if( helper->readEnabled )
389 helper->readTimeout = timeout;
391 log->
Dump(
PollerMsg,
"%s Enable read notifications, timeout: %d",
392 socket->
GetName().c_str(), timeout );
397 bool status = helper->channel->Enable( Channel::readEvents, timeout,
401 log->
Error(
PollerMsg,
"%s Unable to enable read notifications: %s",
402 socket->
GetName().c_str(), errMsg );
406 helper->readEnabled =
true;
414 if( !helper->readEnabled )
423 bool status = helper->channel->Disable( Channel::readEvents, &errMsg );
426 log->
Error(
PollerMsg,
"%s Unable to disable read notifications: %s",
427 socket->
GetName().c_str(), errMsg );
431 helper->readEnabled =
false;
void Dump(uint64_t topic, const char *format,...)
Print a dump message.
References XrdCl::Log::Dump(), XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::Socket::GetName(), XrdCl::PollerMsg, and XrdCl::Log::Warning().
◆ EnableWriteNotification()
bool XrdCl::PollerBuiltIn::EnableWriteNotification |
( |
Socket * |
socket, |
|
|
bool |
notify, |
|
|
uint16_t |
timeout = 60 |
|
) |
| |
|
virtual |
Notify the handler about write events
- Parameters
-
socket | the socket |
notify | specify if the handler should be notified |
timeout | if no write event occurred after this time a timeout event will be generated |
Implements XrdCl::Poller.
Definition at line 439 of file XrdClPollerBuiltIn.cc.
448 log->
Error(
PollerMsg,
"Invalid socket, write events unavailable" );
456 SocketMap::const_iterator it = pSocketMap.find( socket );
457 if( it == pSocketMap.end() )
464 PollerHelper *helper = (PollerHelper*)it->second;
472 if( helper->writeEnabled )
475 helper->writeTimeout = timeout;
477 log->
Dump(
PollerMsg,
"%s Enable write notifications, timeout: %d",
478 socket->
GetName().c_str(), timeout );
483 bool status = helper->channel->Enable( Channel::writeEvents, timeout,
487 log->
Error(
PollerMsg,
"%s Unable to enable write notifications: %s",
488 socket->
GetName().c_str(), errMsg );
492 helper->writeEnabled =
true;
500 if( !helper->writeEnabled )
508 bool status = helper->channel->Disable( Channel::writeEvents, &errMsg );
511 log->
Error(
PollerMsg,
"%s Unable to disable write notifications: %s",
512 socket->
GetName().c_str(), errMsg );
516 helper->writeEnabled =
false;
References XrdCl::Log::Dump(), XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::Socket::GetName(), XrdCl::PollerMsg, and XrdCl::Log::Warning().
◆ Finalize()
bool XrdCl::PollerBuiltIn::Finalize |
( |
| ) |
|
|
virtual |
Finalize the poller.
Implements XrdCl::Poller.
Definition at line 106 of file XrdClPollerBuiltIn.cc.
111 SocketMap::iterator it;
112 for( it = pSocketMap.begin(); it != pSocketMap.end(); ++it )
114 PollerHelper *helper = (PollerHelper*)it->second;
115 if( helper->channel ) helper->channel->Delete();
116 delete helper->callBack;
◆ Initialize()
bool XrdCl::PollerBuiltIn::Initialize |
( |
| ) |
|
|
virtual |
◆ IsRegistered()
bool XrdCl::PollerBuiltIn::IsRegistered |
( |
Socket * |
socket | ) |
|
|
virtual |
Check whether the socket is registered with the poller.
Implements XrdCl::Poller.
Definition at line 524 of file XrdClPollerBuiltIn.cc.
527 SocketMap::iterator it = pSocketMap.find( socket );
528 return it != pSocketMap.end();
◆ IsRunning()
virtual bool XrdCl::PollerBuiltIn::IsRunning |
( |
| ) |
const |
|
inlinevirtual |
◆ RemoveSocket()
bool XrdCl::PollerBuiltIn::RemoveSocket |
( |
Socket * |
socket | ) |
|
|
virtual |
◆ Start()
bool XrdCl::PollerBuiltIn::Start |
( |
| ) |
|
|
virtual |
Start polling.
Implements XrdCl::Poller.
Definition at line 127 of file XrdClPollerBuiltIn.cc.
135 log->
Debug(
PollerMsg,
"Creating and starting the built-in poller..." );
138 const char *errMsg = 0;
140 for(
int i = 0; i < pNbPoller; ++i )
145 log->
Error(
PollerMsg,
"Unable to create the internal poller object: "
149 pPollerPool.push_back( poller );
152 pNext = pPollerPool.begin();
160 SocketMap::iterator it;
161 for( it = pSocketMap.begin(); it != pSocketMap.end(); ++it )
163 PollerHelper *helper = (PollerHelper*)it->second;
164 Socket *socket = it->first;
165 helper->channel =
new IOEvents::Channel( RegisterAndGetPoller( socket ), socket->GetFD(),
167 if( helper->readEnabled )
169 bool status = helper->channel->
Enable( IOEvents::Channel::readEvents,
170 helper->readTimeout, &errMsg );
174 "while re-starting %s (%s)",
XrdSysE2T( errno ), errMsg );
180 if( helper->writeEnabled )
182 bool status = helper->channel->Enable( IOEvents::Channel::writeEvents,
183 helper->writeTimeout, &errMsg );
187 "while re-starting %s (%s)",
XrdSysE2T( errno ), errMsg );
const char * XrdSysE2T(int errcode)
bool Enable(int events, int timeout=0, const char **eText=0)
References Create, XrdCl::Log::Debug(), XrdSys::IOEvents::Channel::Enable(), XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::PollerMsg, and XrdSysE2T().
◆ Stop()
bool XrdCl::PollerBuiltIn::Stop |
( |
| ) |
|
|
virtual |
Stop polling.
Implements XrdCl::Poller.
Definition at line 199 of file XrdClPollerBuiltIn.cc.
208 if( pPollerPool.empty() )
210 log->
Debug(
PollerMsg,
"Stopping a poller that has not been started" );
214 while( !pPollerPool.empty() )
217 pPollerPool.pop_back();
219 if( !poller )
continue;
224 scopedLock.Lock( &pMutex );
226 pNext = pPollerPool.end();
229 SocketMap::iterator it;
230 const char *errMsg = 0;
232 for( it = pSocketMap.begin(); it != pSocketMap.end(); ++it )
234 PollerHelper *helper = (PollerHelper*)it->second;
235 if( !helper->channel )
continue;
236 bool status = helper->channel->Disable( Channel::allEvents, &errMsg );
239 Socket *socket = it->first;
240 log->
Error(
PollerMsg,
"%s Unable to disable write notifications: %s",
241 socket->
GetName().c_str(), errMsg );
243 helper->channel->Delete();
References XrdCl::Log::Debug(), XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::Socket::GetName(), XrdSysMutexHelper::Lock(), XrdCl::PollerMsg, XrdSys::IOEvents::Poller::Stop(), and XrdSysMutexHelper::UnLock().
The documentation for this class was generated from the following files: