Worker thread for multi-threaded socket daemons.
More...
#include <libppbase/base/WorkerThread.h>
List of all members.
Public Member Functions |
| WorkerThread (MTSocketDaemon *daemon, time_t lifetime=0, bool web=false) |
| Constructor.
|
| ~WorkerThread () |
| Destructor.
|
time_t | getLifetime () const |
| Returns the life time.
|
Log * | getLog () |
| Returns the log object.
|
void | getStatus (int *status, String &request, String &addr, u_longlong_t *tv) |
| Retrieves the thread's status.
|
bool | isAuxiliary () const |
| Checks if this thread is an auxiliary one.
|
bool | isWeb () const |
| Checks if this thread is a web thread.
|
void | run () |
| Handles many connections.
|
void | run (Socket *sock) |
| Handles one connection.
|
Protected Member Functions |
virtual void | config () |
| Configures the thread.
|
virtual void | handle ()=0 |
| Handles a connection.
|
bool | readln (String &buf, bool strip=false) |
| Reads a line from the socket, doing debug logging if enabled.
|
void | setStatus (int status, const String &request, const String &addr, u_longlong_t tv=0) |
| Sets the thread's status.
|
void | write (const String &s) |
| Writes data to the socket, doing debug logging if enabled.
|
void | writef (const char *fmt,...) |
| Writes data to the socket, doing debug logging if enabled.
|
Protected Attributes |
String | _addr |
| the ip address of the connected client
|
MTSocketDaemon * | _daemon |
| the multi-threaded socket daemon object
|
time_t | _lifetime |
| time until this thread may live, 0 means infinite
|
Log * | _log |
| logging object
|
WorkPile< Socket * > * | _queue |
| work queue to fetch jobs from
|
Socket * | _sock |
| socket to connected client
|
int | _status |
| thread status: 0=idle, 1=busy
|
String | _status_addr |
| ip address of the connected client
|
String | _status_request |
| currently executed action
|
u_longlong_t | _status_time |
| start time of the currently executed action (ticks)
|
int | _timeout |
| socket timeout in seconds
|
bool | _web |
| flag: this is a web worker thread
|
Detailed Description
Worker thread for multi-threaded socket daemons.
- Author:
- Christoph Schwarz
- Version:
- $Id: WorkerThread.h 21 2010-09-05 04:18:17Z cschwarz1 $
Constructor & Destructor Documentation
base::WorkerThread::WorkerThread |
( |
MTSocketDaemon * |
daemon, |
|
|
time_t |
lifetime = 0 , |
|
|
bool |
web = false | |
|
) |
| | |
Constructor.
- Parameters:
-
| daemon | the daemon |
| lifetime | time until to live (unix timestamp) |
| web | true=web thread, false=worker thread |
Member Function Documentation
time_t base::WorkerThread::getLifetime |
( |
|
) |
const |
Returns the life time.
- Returns:
- the life time as unix timestamp
Log* base::WorkerThread::getLog |
( |
|
) |
|
Returns the log object.
- Returns:
- the log object
Retrieves the thread's status.
- Parameters:
-
| status | returns the status, 0=idle, 1=busy |
| request | returns the currently executed request |
| addr | returns the ip address of the connected client |
| tv | returns the start time of the request (ticks) |
bool base::WorkerThread::isAuxiliary |
( |
|
) |
const |
Checks if this thread is an auxiliary one.
- Returns:
- true=auxiliary, false=primary
bool base::WorkerThread::isWeb |
( |
|
) |
const |
Checks if this thread is a web thread.
- Returns:
- true=web, false=worker
void base::WorkerThread::setStatus |
( |
int |
status, |
|
|
const String & |
request, |
|
|
const String & |
addr, |
|
|
u_longlong_t |
tv = 0 | |
|
) |
| | [protected] |
Sets the thread's status.
- Parameters:
-
| status | 0=idle, 1=busy |
| request | currently executed request |
| addr | ip address of the connected client |
| tv | start time of the request (ticks) |
The documentation for this class was generated from the following file: