Base class for threads. More...
#include <thread.h>


Public Member Functions | |
| thread (const string &nm) | |
| void | start (void) |
| virtual void | run (void) |
| bool | spawn (void) |
| bool | runs (void) |
| value * | nextevent (void) |
| value * | waitevent (void) |
| value * | waitevent (int timeout_msec) |
| void | sendevent (const value &v) |
| void | sendevent (const statstring &type) |
| void | sendevent (const string &type) |
| void | sendevent (const statstring &type, const value &data) |
| void | sendevent (const char *type) |
| int | eventqueue (void) |
| unsigned int | threadid (void) |
| void | setpriority (int prio) |
Static Public Member Functions | |
| static void * | dorun (void *param) |
| static value * | getlist (void) |
Public Attributes | |
| bool | finished |
| string | threadname |
Protected Attributes | |
| pthread_t | tid |
| pthread_attr_t | attr |
| sched_param | schedparam |
| bool | spawned |
| eventq | events |
| lock< bool > | isrunning |
Base class for threads.
Derived classes can use this class to spawn into a background thread.
| void * thread::dorun | ( | void * | param | ) | [static] |
Static method to start thread.
Used as an argument for the system thread create.
| param | Pointer to the thread object. |
References string::printf(), and threadname.
Referenced by spawn().

| int thread::eventqueue | ( | void | ) | [inline] |
Measure the queue size.
References eventq::count(), and events.

| value* thread::nextevent | ( | void | ) | [inline] |
Get the next event from the queue.
The run method can call this to peek at any incoming events.
References events, and eventq::nextevent().
Referenced by smtpworker::run(), and httpdworker::run().

| bool thread::runs | ( | void | ) |
| void thread::sendevent | ( | const statstring & | type, | |
| const value & | data | |||
| ) | [inline] |
Send an event without data to the thread.
The receiving thread will get a value-object with a a type() set to your liking and the data from the value you supply.
| type | The event-type. | |
| data | The event data. |
References events, and eventq::send().

| void thread::sendevent | ( | const string & | type | ) | [inline] |
Send an event without data to the thread.
The receiving thread will get a value-object with a a type() set to your liking and a boolean value of 'true'.
| type | The event-type. |
References events, and eventq::send().

| void thread::sendevent | ( | const statstring & | type | ) | [inline] |
Send an event without data to the thread.
The receiving thread will get a value-object with a a type() set to your liking and a boolean value of 'true'.
| type | The event-type. |
References events, and eventq::send().

| void thread::sendevent | ( | const value & | v | ) | [inline] |
Send an event to the thread.
Other threads can call this method to dispatch commands or other events. The receiving thread will get this value with a type() of "event".
| v | The event data. |
References events, and eventq::send().
Referenced by daemon::log(), httpd::shutdown(), and logthread::shutdown().

| void thread::setpriority | ( | int | prio | ) | [inline] |
| bool thread::spawn | ( | void | ) |
Spawn the thread in the background.
| threadCreateException | Error creating a thread. |
References attr, dorun(), isrunning, spawned, and tid.
Referenced by httpdworker::httpdworker(), smtpworker::smtpworker(), start(), smtpd::start(), and httpd::start().

| void thread::start | ( | void | ) | [inline] |
| unsigned int thread::threadid | ( | void | ) | [inline] |
Find out thread's unique id.
Referenced by smtpworker::run(), and httpdworker::run().
| value* thread::waitevent | ( | int | timeout_msec | ) | [inline] |
Block waiting for an event on the queue, with timeout.
The run method can call this to wait for work.
| timeout_msec | The timeout in milliseconds. |
References events, and eventq::waitevent().

| value* thread::waitevent | ( | void | ) | [inline] |
Block waiting for an event on the queue.
The run method can call this to wait for work.
References events, and eventq::waitevent().
Referenced by httpd::run(), and logthread::run().

1.6.1