Creates a pool of threads and a pool of tasks to be executed by the threads simultaneously.
Expected use of this class follows:
- Note
- The API is not guaranteed to be thread safe. This class is provided to speed up build and load processes among others which are necessary but not part of the API. Use it with caution.
#include <include/maliput/utility/thread_pool.h>
◆ ThreadPool()
Creates a pool of n
threads.
- Parameters
-
n | Is the number of threads to be managed. |
- Exceptions
-
◆ ~ThreadPool()
◆ cancel_pending()
Cancels all non-started tasks.
◆ Finish()
Finishes the threads.
Waits for all tasks previously added to finish before destroying the threads.
◆ is_running()
- Returns
- True when the threads are already started.
◆ MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN()
◆ Queue()
std::future<R> Queue |
( |
F && |
f | ) |
|
Adds tasks to the queue.
- Template Parameters
-
- Parameters
-
- Template Parameters
-
R | Is the functors return type. @return A std::future<R> that will hold the result of f`. |
- Exceptions
-
◆ Start()
Starts the threads to work on the tasks.
The main thread will not perform any task and will continue the execution.
- Exceptions
-
The documentation for this class was generated from the following files: