c++-gtk-utils
|
A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager object will run. More...
#include <c++-gtk-utils/task_manager.h>
Public Member Functions | |
IncHandle (TaskManager &tm_) | |
~IncHandle () | |
A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager object will run.
This class is for use where a task running on a TaskManager object is about to make a blocking call. It enables the task to increment in an exception safe way the maximum number of tasks which the TaskManager object will currently run in its thread pool to enable another thread to keep a core active, so that the number is automatically decremented again when the ThreadManager::IncHandle object has gone out of scope after the task has finished making blocking calls or something has thrown.
The documentation on Thread::TaskManager gives an example of its use.
This class is available since version 1.2.31 of the library.
|
inlineexplicit |
This constructor calls TaskManager::change_max_threads() to increment the maximum number of threads a TaskManager object will currently run in its thread pool.
tm_ | The TaskManager object whose maximum thread limit is to be incremented. |
std::bad_alloc | If tasks are currently queued for execution, a new thread will be started, so this exception may be thrown on starting the thread if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). |
Cgu::Thread::TaskError | If tasks are currently queued for execution, a new thread will be started, so this exception may be thrown on starting the thread if it fails to start correctly (this would mean that memory is exhausted, the pthread thread limit has been reached or pthread has run out of other resources to start new threads). |
Since 1.2.31
|
inline |
This destructor calls TaskManager::change_max_threads() to decrement the maximum number of threads a TaskManager object will currently run in its thread pool. It will not throw.
Since 1.2.31