The SocketService is a thread pool object that is meant to service attached socket ports.
More...
#include <socketport.h>
|
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, size_t stack=0, const char *id=NULL) |
| 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...
|
|
| Thread (bool isMain) |
| This is actually a special constructor that is used to create a thread "object" for the current execution context when that context is not created via an instance of a derived Thread object itself. More...
|
|
| Thread (int pri=0, size_t stack=0) |
| When a thread object is contructed, a new thread of execution context is created. More...
|
|
| Thread (const Thread &th) |
| A thread of execution can also be specified by cloning an existing thread. More...
|
|
virtual | ~Thread () |
| The thread destructor should clear up any resources that have been allocated by the thread. More...
|
|
int | start (Semaphore *start=0) |
| When a new thread is created, it does not begin immediate execution. More...
|
|
int | detach (Semaphore *start=0) |
| Start a new thread as "detached". More...
|
|
Thread * | getParent (void) |
| Gets the pointer to the Thread class which created the current thread object. More...
|
|
void | suspend (void) |
| Suspends execution of the selected thread. More...
|
|
void | resume (void) |
| Resumes execution of the selected thread. More...
|
|
Cancel | getCancel (void) |
| Used to retrieve the cancellation mode in effect for the selected thread. More...
|
|
bool | isRunning (void) const |
| Verifies if the thread is still running or has already been terminated but not yet deleted. More...
|
|
bool | isDetached (void) const |
| Check if this thread is detached. More...
|
|
void | join (void) |
| Blocking call which unlocks when thread terminates. More...
|
|
bool | isThread (void) const |
| Tests to see if the current execution context is the same as the specified thread object. More...
|
|
cctid_t | getId (void) const |
| Get system thread numeric identifier. More...
|
|
const char * | getName (void) const |
| Get the name string for this thread, to use in debug messages. More...
|
|
|
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...
|
|
void | setName (const char *text) |
| Set the name of the current thread. More...
|
|
virtual void | final (void) |
| A thread that is self terminating, either by invoking exit() or leaving it's run(), will have this method called. More...
|
|
virtual void | initial (void) |
| The initial method is called by a newly created thread when it starts execution. More...
|
|
virtual void * | getExtended (void) |
| Since getParent() and getThread() only refer to an object of the Thread "base" type, this virtual method can be replaced in a derived class with something that returns data specific to the derived class that can still be accessed through the pointer returned by getParent() and getThread(). More...
|
|
virtual void | notify (Thread *) |
| When a thread terminates, it now sends a notification message to the parent thread which created it. More...
|
|
void | exit (void) |
| Used to properly exit from a Thread derived run() or initial() method. More...
|
|
void | sync (void) |
| Used to wait for a join or cancel, in place of explicit exit. More...
|
|
bool | testCancel (void) |
| test a cancellation point for deferred thread cancellation. More...
|
|
void | setCancel (Cancel mode) |
| Sets thread cancellation mode. More...
|
|
void | setSuspend (Suspend mode) |
| Sets the thread's ability to be suspended from execution. More...
|
|
void | terminate (void) |
| Used by another thread to terminate the current thread. More...
|
|
void | clrParent (void) |
| clear parent thread relationship. More...
|
|
The SocketService is a thread pool object that is meant to service attached 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.nosp@m.@ost.nosp@m.el.co.nosp@m.m Thread pool service object for socket ports.
- Examples:
- tcpservice.cpp.
◆ SocketService()
ost::SocketService::SocketService |
( |
int |
pri = 0 , |
|
|
size_t |
stack = 0 , |
|
|
const char * |
id = NULL |
|
) |
| |
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. |
stack | stack size. |
id | thread ID. |
◆ ~SocketService()
virtual ost::SocketService::~SocketService |
( |
| ) |
|
|
virtual |
Terminate the thread pool and eliminate any attached socket ports.
◆ getCount()
int ost::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.
◆ onCallback()
virtual void ost::SocketService::onCallback |
( |
SocketPort * |
port | ) |
|
|
protectedvirtual |
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
-
port | SocketPort who's callback events are being evaluated. |
◆ onEvent()
virtual void ost::SocketService::onEvent |
( |
void |
| ) |
|
|
protectedvirtual |
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.
◆ onUpdate()
virtual void ost::SocketService::onUpdate |
( |
unsigned char |
buf | ) |
|
|
protectedvirtual |
Handles all requests other than "termination".
- Parameters
-
◆ update()
void ost::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
-
◆ SocketPort
The documentation for this class was generated from the following file: