Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

SocketService Class Reference

The SocketService is a thread pool object that is meant to service attached socket ports. Thread pool service object for socket ports. More...

#include <socket.h>

Inheritance diagram for SocketService::

Thread Mutex List of all members.

Public Methods

void Update (unsigned char flag=0xff)
 Notify service thread that a port has been added or removed, or a timer changed, so that a new schedule can be computed for expiring attached ports. More...

 SocketService (int pri=0)
 Create a service thread for attaching socket ports. More...

virtual ~SocketService ()
 Terminate the thread pool and eliminate any attached socket ports. More...

int getCount (void) const
 Get current reference count. More...


Protected Methods

virtual void OnUpdate (unsigned char buf)
 Handles all requests other than "termination". More...

virtual void OnEvent (void)
 Called once each time the service thread is rescheduled. More...

virtual void OnCallback (SocketPort *port)
 Called for each port that is being processed in response to an event. More...


Friends

class SocketPort

Detailed Description

The SocketService is a thread pool object that is meant to service attached socket ports. Thread pool service object for socket ports.

Multiple pool objects may be created and multiple socket ports may be attached to the same thread of execution. This allows one to balance threads and sockets they service rather than either using a single thread for all connections or a seperate thread for each connection. Features can be added through supported virtual methods.

Author:
David Sugar <dyfet@ostel.com>


Constructor & Destructor Documentation

SocketService::SocketService int   pri = 0
 

Create a service thread for attaching socket ports.

The thread begins execution with the first attached socket.

Parameters:
pri   of this thread to run under.

virtual SocketService::~SocketService   [virtual]
 

Terminate the thread pool and eliminate any attached socket ports.


Member Function Documentation

virtual void SocketService::OnCallback SocketPort *   port [inline, protected, virtual]
 

Called for each port that is being processed in response to an event.

This can be used to add additional notification options during callback in combination with Update().

Parameters:
SocketPort   who's callback events are being evaluated.

virtual void SocketService::OnEvent void   [inline, protected, virtual]
 

Called once each time the service thread is rescheduled.

This is called after the mutex is locked and can be used to slip in additional processing.

virtual void SocketService::OnUpdate unsigned char   buf [inline, protected, virtual]
 

Handles all requests other than "termination".

Parameters:
request   id as posted from Update().

void SocketService::Update unsigned char   flag = 0xff
 

Notify service thread that a port has been added or removed, or a timer changed, so that a new schedule can be computed for expiring attached ports.

A "0" is used to terminate the service thread, and additional values can be specified which will be "caught" in the OnUpdate() handler.

Parameters:
Update   flag value.

int SocketService::getCount void   const [inline]
 

Get current reference count.

This can be used when selecting the least used service handler from a pool.

Returns:
count of active ports.


Friends And Related Function Documentation

friend class SocketPort [friend]
 


The documentation for this class was generated from the following file:
Generated at Tue Nov 20 12:34:37 2001 for CommonC++ by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001