Portability Libraries  2015.2.0.0
Common Methods and Objects for Platform Independance.
SoftwareAndServices::Library::Common::Poll Class Reference

#include "<SaS/Common/Poll.hpp>"

+ Inheritance diagram for SoftwareAndServices::Library::Common::Poll:
+ Collaboration diagram for SoftwareAndServices::Library::Common::Poll:

Classes

struct  CallBacks
 

Public Member Functions

 Poll ()
 
virtual ~Poll ()
 
bool AddFd (const int fd, const unsigned short events, const CallBacks *cb=NULL)
 
void CloseDown ()
 
void Disable (const int fd, const unsigned short events)
 
void Enable (const int fd, const unsigned short events)
 
FileGetFile (const int fd)
 
PollFunc_t GetTAcceptCallback () const
 
PollFunc_t GetTCallback (const int fd, const unsigned short events) const
 
void * GetTData () const
 
PollFunc_t GetTDefaultCallback (const unsigned short events) const
 
PollFunc_t GetUserAcceptCallback () const
 
PollFunc_t GetUserCallback (const int fd, unsigned short events) const
 
void * GetUserData () const
 
PollFunc_t GetUserDefaultCallback (const unsigned short events) const
 
void Lock ()
 
const struct pollfd * PollFd () const
 
nfds_t PollFdSize () const
 
bool RemoveFd (const int fd)
 
void SetTAcceptCallback (const PollFunc_t ThePollFunc, const void *userData=NULL)
 
void SetTCallback (const int fd, const unsigned short events, const PollFunc_t ThePollFunc, const unsigned int bufSize)
 
void SetTData (const void *Data)
 
void SetTDefaultCallback (const unsigned short events, const PollFunc_t ThePollFunc, const unsigned int bufSize)
 
void SetTFillRdCallback (const int fd, const unsigned short events, const PollFunc_t ThePollFunc, const unsigned int bufsize)
 
void SetTimeout (const int milliseconds)
 
void SetUserAcceptCallback (const PollFunc_t ThePollFunc, const void *userData=NULL)
 
void SetUserCallback (const int fd, const unsigned short events, const PollFunc_t ThePollFunc, const unsigned int bufSize)
 
void SetUserData (const void *Data)
 
void SetUserData (int fd, const void *Data)
 
void SetUserDefaultCallback (const unsigned short events, const PollFunc_t ThePollFunc, const unsigned int bufSize=0)
 
void SetUserFillRdCallback (const int fd, const unsigned short events, const PollFunc_t ThePollFunc, const unsigned int bufsize)
 
void TDisable (const int fd, const unsigned short events)
 
void TEnable (const int fd, const unsigned short events)
 
void Unlock ()
 
void UserDisable (const int fd, const unsigned short events)
 
void UserEnable (const int fd, const unsigned short events)
 
int Wait (bool Once=false)
 
int WakeUpFd () const
 
- Public Member Functions inherited from SoftwareAndServices::Library::Common::instance< Poll >
 instance ()
 
virtual InstanceCount_t decInstance () const
 
virtual InstanceCount_t getInstance () const
 
virtual InstanceCount_t incInstance () const
 
void operator delete (void *ToFree)
 

Static Public Member Functions

static void * GetUserData (int fd)
 

Public Attributes

EXPORT_COMMON typedef int(* PollFunc_t )(const int fd, const unsigned short revents, CallBacks *callBacks, const unsigned int len, const char *data)
 

Friends

void * _WakeUpThread (void *)
 
void AtExitCleanup ()
 

Detailed Description

An OS independent wrapper for polling I/O connections.

Poll Events:

  • POLLIN Data other than high priority data may be read without blocking. For STREAMS, this flag is set in revents even if the message is of zero length.
  • POLLRDBAND Data from a non-zero priority band may be read without blocking. For STREAMS, this flag is set in revents even if the message is of zero length.
  • POLLPRI High priority data may be received without blocking. For STREAMS, this flag is set in revents even if the message is of zero length.
  • POLLOUT Normal data (priority band equals 0) may be written without blocking.
Warning
POLLOUT will generate a massive amount of callback calls as most devices are almost always ready to be written to. Suggest only using this for extremely slow devices where you really need to know if it can be written to.
  • POLLWRBAND Priority data (priority band > 0) may be written. This event only examines bands that have been written to at least once.
  • POLLERR An error has occurred on the device or stream. This flag is only valid in the revents bitmask; it is not used in the events member.
  • POLLHUP A hang-up has occurred on the stream. This event and POLLOUT are mutually exclusive; a stream can never be writable if a hang-up has occurred. However, this event and POLLIN, POLLRDBAND, or POLLPRI are not mutually exclusive. This flag is only valid in the revents bitmask; it is not used in the events member.
  • POLLNVAL The specified fd value does not belong to an open file. This flag is only valid in the revents member; it is not used in the events member.

This implementation has two level, the OS level (T meaning transport) and the user level (User).

The User level is what the calling program uses to set or get data or callbacks.

The T level is the implementation specific level. Normally calling program never use the T level.

This implementation uses the POSIX poll() on systems that have it, or a private implementation that uses select() on systems that have that.

In addition to emulating the features of POSIX poll() this implementation will buffer in or out the data. The caller can for example pass a buffer down and have this implementation send it (or fill it) to/from the designated FD asynchronously of the calling program. Then callback the calling programs handler to notify it that the task is complete.

Definition at line 237 of file Poll.hpp.


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