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 (const TaskManager::IncHandle &)=delete | |
TaskManager::IncHandle & | operator= (const TaskManager::IncHandle &)=delete |
IncHandle ()=delete | |
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 2.0.18 of the library.
|
delete |
This class cannot be copied. The copy constructor is deleted.
Since 2.0.18
|
delete |
This class requires initialisation with a TaskManager object. The default constructor is deleted.
Since 2.0.18
|
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 2.0.18
|
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 2.0.18
|
delete |
This class cannot be copied. The assignment operator is deleted.
Since 2.0.18