knowrob
2.1.0
A Knowledge Base System for Cognition-enabled Robots
|
#include <ThreadPool.h>
Classes | |
class | LambdaRunner |
class | Runner |
class | Worker |
Public Types | |
using | ExceptionHandler = std::function< void(const std::exception &)> |
using | ExceptionHandler = std::function< void(const std::exception &)> |
Public Member Functions | |
ThreadPool (uint32_t maxNumThreads) | |
virtual | ~ThreadPool () |
ThreadPool (const ThreadPool &)=delete | |
void | shutdown () |
void | pushWork (const std::shared_ptr< ThreadPool::Runner > &goal, ThreadPool::ExceptionHandler exceptionHandler) |
ThreadPool (uint32_t maxNumThreads) | |
virtual | ~ThreadPool () |
ThreadPool (const ThreadPool &)=delete | |
void | shutdown () |
void | pushWork (const std::shared_ptr< ThreadPool::Runner > &goal, ThreadPool::ExceptionHandler exceptionHandler) |
Protected Attributes | |
std::function< void()> | finalizeWorker_ |
A pool of worker threads waiting on tasks to be pushed into a work queue.
Definition at line 27 of file ThreadPool.h.
using knowrob::ThreadPool::ExceptionHandler = std::function<void(const std::exception &)> |
Definition at line 32 of file ThreadPool.h.
using knowrob::ThreadPool::ExceptionHandler = std::function<void(const std::exception &)> |
Definition at line 32 of file ThreadPool.h.
|
explicit |
maxNumThreads | the maximum number of worker threads |
Definition at line 26 of file ThreadPool.cpp.
|
virtual |
Definition at line 37 of file ThreadPool.cpp.
|
delete |
Cannot be copy-assigned.
|
explicit |
maxNumThreads | the maximum number of worker threads |
|
virtual |
|
delete |
Cannot be copy-assigned.
void ThreadPool::pushWork | ( | const std::shared_ptr< ThreadPool::Runner > & | goal, |
ThreadPool::ExceptionHandler | exceptionHandler | ||
) |
Pushes a goal for a worker. The goal is assigned to a worker thread when one is available.
goal | the work goal |
exceptionHandler | an exception handler |
Definition at line 70 of file ThreadPool.cpp.
void knowrob::ThreadPool::pushWork | ( | const std::shared_ptr< ThreadPool::Runner > & | goal, |
ThreadPool::ExceptionHandler | exceptionHandler | ||
) |
Pushes a goal for a worker. The goal is assigned to a worker thread when one is available.
goal | the work goal |
exceptionHandler | an exception handler |
void ThreadPool::shutdown | ( | ) |
Shutdown the thread pool. Joining all the worker threads. If one of them is busy, this call will block until the worker has finished its work, and can gracefully exit.
Definition at line 41 of file ThreadPool.cpp.
void knowrob::ThreadPool::shutdown | ( | ) |
Shutdown the thread pool. Joining all the worker threads. If one of them is busy, this call will block until the worker has finished its work, and can gracefully exit.
|
protected |
Definition at line 168 of file ThreadPool.h.