#include <thread_pool.hh>

Public Types | |
| typedef unsigned int | count_type |
| Thread count data type. | |
Public Member Functions | |
| thread_pool (count_type num) | |
| Thread pool constructor. | |
| virtual | ~thread_pool (void) |
| Destructor. | |
| count_type | capacity (void) const |
| Get the maximum number of threads. | |
| count_type | count (void) const |
| virtual void | thread_entry (void) |
| Process method. | |
| count_type | get_busy (void) const |
| Number of busy threads. | |
| count_type | get_max_busy (void) const |
| Maximum number of busy threads. | |
| void | lock (void) |
| Lock the thread pool. | |
| void | make_threads (void) |
| Create threads. | |
| void | set_size (count_type N) |
| Set number of threads. | |
| count_type | size (void) const |
| void | unlock (void) |
| Unlock the thread pool. | |
| void | wait_empty (void) |
| Wait for the end. | |
Static Public Member Functions | |
| static void * | thread_exec (void *tp) |
| Thread start method. | |
Protected Member Functions | |
| count_type | busy (void) |
| Current thread is busy. | |
| void | done (void) |
| Current thread is done. | |
| bool | test_run (void) |
The thread pool base class contains the API of the thread procedure to be performed by each thread in the pool and status and control information for the pool as a whole, including:
| typedef unsigned int sends::thread_pool::count_type |
Thread count data type.
Data type used to specify thread counts.
| sends::thread_pool::thread_pool | ( | count_type | num | ) |
Thread pool constructor.
Construct a thread pool, specifying the number of threads to be run concurrently. Threads aren't created until the user calls make threads after completing any initialization needed.
| num | Number of threads to be run concurrently. |
| virtual sends::thread_pool::~thread_pool | ( | void | ) | [virtual] |
Destructor.
Destroy a thread pool.
| static void* sends::thread_pool::thread_exec | ( | void * | tp | ) | [static] |
Thread start method.
This method is used to start up the thread class.
| tp | Pointer to the class to be |
| thread_pool::count_type sends::thread_pool::capacity | ( | void | ) | const [inline] |
Get the maximum number of threads.
Get the current maximum number of threads to run concurrently.
| thread_pool::count_type sends::thread_pool::count | ( | void | ) | const [inline] |
Return the number of events the threads have processed. This counter is incremented by each transition of a thread to the busy state.
| virtual void sends::thread_pool::thread_entry | ( | void | ) | [virtual] |
| thread_pool::count_type sends::thread_pool::get_busy | ( | void | ) | const [inline] |
Number of busy threads.
Number of threads in the busy state.
| thread_pool::count_type sends::thread_pool::get_max_busy | ( | void | ) | const [inline] |
Maximum number of busy threads.
High water mark for threads in the busy state.
| void sends::thread_pool::lock | ( | void | ) |
Lock the thread pool.
Lock the thread pool status information for modification.
| void sends::thread_pool::make_threads | ( | void | ) |
Create threads.
Create as many threads as necessary to bring the current number to max_threads.
| void sends::thread_pool::set_size | ( | count_type | N | ) |
Set number of threads.
Set the maximum number of threads.
| N | Number of threads. |
| thread_pool::count_type sends::thread_pool::size | ( | void | ) | const [inline] |
Get the current number of running threads.
| void sends::thread_pool::unlock | ( | void | ) |
Unlock the thread pool.
Unlock the thread pool status and control information.
| void sends::thread_pool::wait_empty | ( | void | ) |
Wait for the end.
Wait for the thread pool to empty out.
| count_type sends::thread_pool::busy | ( | void | ) | [protected] |
Current thread is busy.
Indicate the the current thread is busy. The busy count and use count are incremented.
| void sends::thread_pool::done | ( | void | ) | [protected] |
Current thread is done.
Indicate the the current thread has finished. The busy count is decremented.
| bool sends::thread_pool::test_run | ( | void | ) | [protected] |
test whether the thread is to continue running. Note that the thread must test its run state periodically and terminate immediately if the return value is false.
1.5.5