cxxtools::ThreadPool Class Reference

#include <cxxtools/threadpool.h>

Classes

class  Future
 The Future class monitors the state of a job, which runs in the thread pool. More...

Public Member Functions

 ThreadPool (unsigned size, bool doStart=true)
 Creates a thread pool structure.
 ~ThreadPool ()
 Destroys a thread pool structure.
void start ()
 Explict start of the thread pool.
void stop (bool cancel=false)
 Stops the thread of the thread pool.
Future schedule (const Callable< void > &cb)
 Schedules a task to be processed.
bool running () const
 Returns true, if the threadpool is in running state.
bool stopped () const
 Returns true, if the threadpool is in stopped state.

Constructor & Destructor Documentation

cxxtools::ThreadPool::ThreadPool ( unsigned  size,
bool  doStart = true 
)
explicit

Creates a thread pool structure.

When the argument doStart is set to true (which is the default), the threads are started.

cxxtools::ThreadPool::~ThreadPool ( )

Destroys a thread pool structure.

Before destruction all jobs are processed and the threads are stopped.

Member Function Documentation

bool cxxtools::ThreadPool::running ( ) const

Returns true, if the threadpool is in running state.

Future cxxtools::ThreadPool::schedule ( const Callable< void > &  cb)

Schedules a task to be processed.

The task is processed by the next available thread.

void cxxtools::ThreadPool::start ( )

Explict start of the thread pool.

void cxxtools::ThreadPool::stop ( bool  cancel = false)

Stops the thread of the thread pool.

All threads of this pool are stopped. The current job is finished. Remaining jobs are discarded, when cancel is set. Otherwise the threads stop, when the queue is empty.

bool cxxtools::ThreadPool::stopped ( ) const

Returns true, if the threadpool is in stopped state.


The documentation for this class was generated from the following file: