Cgu::Thread::TaskManager::IncHandle Class Reference

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 ()

## Detailed Description

A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager object will run.

See also
  Thread::TaskManager

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.2.1 of the library.

## Constructor & Destructor Documentation

## IncHandle() [1/3]

Cgu::Thread::TaskManager::IncHandle::IncHandle | ( | const TaskManager::IncHandle & |  | ) |

delete

This class cannot be copied. The copy constructor is deleted.

Since 2.0.18/2.2.1

## IncHandle() [2/3]

Cgu::Thread::TaskManager::IncHandle::IncHandle | ( |  | ) |

delete

This class requires initialisation with a TaskManager object. The default constructor is deleted.

Since 2.0.18/2.2.1

## IncHandle() [3/3]

Cgu::Thread::TaskManager::IncHandle::IncHandle | ( | TaskManager & | tm_ | ) |

inline explicit

This constructor calls TaskManager::change_max_threads() to increment the maximum number of threads a TaskManager object will currently run in its thread pool.

Parameters

  tm_ | The TaskManager object whose maximum thread limit is to be incremented.

Exceptions

  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/2.2.1

## ~IncHandle()

Cgu::Thread::TaskManager::IncHandle::~IncHandle | ( |  | ) |

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/2.2.1

## Member Function Documentation

## operator=()

TaskManager::IncHandle& Cgu::Thread::TaskManager::IncHandle::operator= | ( | const TaskManager::IncHandle & |  | ) |

delete

This class cannot be copied. The assignment operator is deleted.

Since 2.0.18/2.2.1

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

- task_manager.h