My Project
Public Member Functions | Public Attributes | List of all members
core::EPoll Class Reference

#include <EPoll.h>

Inheritance diagram for core::EPoll:
Inheritance graph
[legend]
Collaboration diagram for core::EPoll:
Collaboration graph
[legend]

Public Member Functions

 EPoll ()
 
 ~EPoll ()
 
bool start (int numberOfThreads, int maxSockets)
 Start the BMAEPoll processing. More...
 
bool stop ()
 Stop and shut down the BMAEPoll processing. More...
 
bool isStopping ()
 Returns a true if the stop command has been requested. More...
 
bool registerSocket (Socket *socket)
 Register a BMASocket for monitoring by BMAEPoll. More...
 
bool unregisterSocket (Socket *socket)
 Unregister a BMASocket from monitoring by BMAEPoll. More...
 
int getDescriptor ()
 Return the descriptor for the ePoll socket. More...
 
void eventReceived (struct epoll_event event)
 Dispatch event to appropriate socket. More...
 
int processCommand (coreutils::ZString &request, TCPSession &session) override
 Output the threads array to the console. More...
 
void resetSocket (Socket *socket)
 
- Public Member Functions inherited from core::Command
virtual void output (std::stringstream &out)
 

Public Attributes

int maxSockets
 The maximum number of socket allowed. More...
 

Detailed Description

EPoll

Manage socket events from the epoll system call.

Use this object to establish a socket server using the epoll network structure of Linux.

Use this object to establish the basis of working with multiple sockets of all sorts using the epoll capabilities of the Linux platform. Socket objects can register with EPoll which will establish a communication mechanism with that socket.

The maximum number of sockets to communicate with is specified on the start method.

Threads are used to establish a read queue for epoll. The desired number of threads (or queues) is established by a parameter on the start method.

Constructor & Destructor Documentation

◆ EPoll()

core::EPoll::EPoll ( )

The constructor for the BMAEPoll object.

◆ ~EPoll()

core::EPoll::~EPoll ( )

The destructor for the BMAEPoll object.

Member Function Documentation

◆ eventReceived()

void core::EPoll::eventReceived ( struct epoll_event  event)

Dispatch event to appropriate socket.

Receive the epoll events and dispatch the event to the socket making the request.

◆ getDescriptor()

int core::EPoll::getDescriptor ( )

Return the descriptor for the ePoll socket.

Use this method to obtain the current descriptor socket number for the epoll function call.

◆ isStopping()

bool core::EPoll::isStopping ( )

Returns a true if the stop command has been requested.

This method returns a true if the stop() method has been called and the epoll system is shutting.

◆ processCommand()

int core::EPoll::processCommand ( coreutils::ZString &  request,
TCPSession session 
)
overridevirtual

Output the threads array to the console.

The processCommand() method displays the thread array to the requesting console via the session passed as parameter.

Parameters
sessionthe session to write the requested data to.

Reimplemented from core::Command.

◆ registerSocket()

bool core::EPoll::registerSocket ( Socket socket)

Register a BMASocket for monitoring by BMAEPoll.

Use registerSocket to add a new socket to the ePoll event watch list. This enables a new BMASocket object to receive events when data is received as well as to write data output to the socket.

Parameters
socketa pointer to a BMASocket object.
Returns
a booelean that indicates the socket was registered or not.

◆ start()

bool core::EPoll::start ( int  numberOfThreads,
int  maxSockets 
)

Start the BMAEPoll processing.

Use the start() method to initiate the threads and begin epoll queue processing.

Parameters
numberOfThreadsthe number of threads to start for processing epoll entries.
maxSocketsthe maximum number of open sockets that epoll will manage.

◆ stop()

bool core::EPoll::stop ( )

Stop and shut down the BMAEPoll processing.

Use the stop() method to initiate the shutdown process for the epoll socket management.

A complete shutdown of all managed sockets will be initiated by this method call.

◆ unregisterSocket()

bool core::EPoll::unregisterSocket ( Socket socket)

Unregister a BMASocket from monitoring by BMAEPoll.

Use this method to remove a socket from receiving events from the epoll system.

Member Data Documentation

◆ maxSockets

int core::EPoll::maxSockets

The maximum number of socket allowed.

The maximum number of sockets that can be managed by the epoll system.


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