InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | List of all members
PollEngine Class Reference
Inheritance diagram for PollEngine:
SocketEngine

Public Member Functions

 PollEngine ()
 
virtual ~PollEngine ()
 
virtual bool AddFd (EventHandler *eh, int event_mask)
 
virtual void OnSetEvent (EventHandler *eh, int old_mask, int new_mask)
 
virtual EventHandlerGetRef (int fd)
 
virtual void DelFd (EventHandler *eh)
 
virtual int DispatchEvents ()
 
virtual std::string GetName ()
 
- Public Member Functions inherited from SocketEngine
 SocketEngine ()
 
virtual ~SocketEngine ()
 
void ChangeEventMask (EventHandler *eh, int event_mask)
 
int GetMaxFds () const
 
int GetUsedFds () const
 
virtual bool HasFd (int fd)
 
virtual void DispatchTrialWrites ()
 
virtual bool BoundsCheckFd (EventHandler *eh)
 
int Accept (EventHandler *fd, sockaddr *addr, socklen_t *addrlen)
 
int Close (EventHandler *fd)
 
int Close (int fd)
 
int Send (EventHandler *fd, const void *buf, size_t len, int flags)
 
int Recv (EventHandler *fd, void *buf, size_t len, int flags)
 
int RecvFrom (EventHandler *fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen)
 
int SendTo (EventHandler *fd, const void *buf, size_t len, int flags, const sockaddr *to, socklen_t tolen)
 
int Connect (EventHandler *fd, const sockaddr *serv_addr, socklen_t addrlen)
 
int Blocking (int fd)
 
int NonBlocking (int fd)
 
int Shutdown (EventHandler *fd, int how)
 
int Shutdown (int fd, int how)
 
int Bind (int fd, const irc::sockets::sockaddrs &addr)
 
int Listen (int sockfd, int backlog)
 
void SetReuse (int sockfd)
 
virtual void RecoverFromFork ()
 
void GetStats (float &kbitpersec_in, float &kbitpersec_out, float &kbitpersec_total)
 

Additional Inherited Members

- Static Public Member Functions inherited from SocketEngine
static bool IgnoreError ()
 
static std::string LastError ()
 
static std::string GetError (int errnum)
 
- Public Attributes inherited from SocketEngine
unsigned long TotalEvents
 
unsigned long ReadEvents
 
unsigned long WriteEvents
 
unsigned long ErrorEvents
 
- Protected Member Functions inherited from SocketEngine
void UpdateStats (size_t len_in, size_t len_out)
 
void SetEventMask (EventHandler *eh, int value)
 
- Protected Attributes inherited from SocketEngine
int CurrentSetSize
 
EventHandler ** ref
 
std::set< int > trials
 
int MAX_DESCRIPTORS
 
size_t indata
 
size_t outdata
 
time_t lastempty
 

Detailed Description

A specialisation of the SocketEngine class, designed to use poll().

Constructor & Destructor Documentation

PollEngine::PollEngine ( )

Create a new PollEngine

PollEngine::~PollEngine ( )
virtual

Delete a PollEngine

Member Function Documentation

bool PollEngine::AddFd ( EventHandler eh,
int  event_mask 
)
virtual

Add an EventHandler object to the engine. Use AddFd to add a file descriptor to the engine and have the socket engine monitor it. You must provide an object derived from EventHandler which implements HandleEvent().

Parameters
ehAn event handling object to add
event_maskThe initial event mask for the object

Implements SocketEngine.

void PollEngine::DelFd ( EventHandler eh)
virtual

Delete an event handler from the engine. This function call deletes an EventHandler from the engine, returning true if it succeeded and false if it failed. This does not free the EventHandler pointer using delete, if this is required you must do this yourself.

Parameters
ehThe event handler object to remove

Implements SocketEngine.

int PollEngine::DispatchEvents ( )
virtual

Waits for events and dispatches them to handlers. Please note that this doesn't wait long, only a couple of milliseconds. It returns the number of events which occurred during this call. This method will dispatch events to their handlers by calling their EventHandler::HandleEvent() methods with the necessary EventType value.

Returns
The number of events which have occured.

Implements SocketEngine.

std::string PollEngine::GetName ( )
virtual

Returns the socket engines name. This returns the name of the engine for use in /VERSION responses.

Returns
The socket engine name

Implements SocketEngine.

EventHandler * PollEngine::GetRef ( int  fd)
virtual

Returns the EventHandler attached to a specific fd. If the fd isnt in the socketengine, returns NULL.

Parameters
fdThe event handler to look for
Returns
A pointer to the event handler, or NULL

Reimplemented from SocketEngine.


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