Task queue with a thread pool.
More...
#include <tkrzw_thread_util.h>
|
| typedef std::function< void()> | TaskLambdaType |
| | Lambda function type to do a task.
|
| |
|
| | TaskQueue () |
| | Default constructor.
|
| |
| | ~TaskQueue () |
| | Destructor.
|
| |
| void | Start (int32_t num_worker_threads) |
| | Starts worker threads.
|
| |
| void | Stop (double timeout) |
| | Stops worker threads.
|
| |
| void | Add (std::unique_ptr< Task > task) |
| | Adds a task to the queue.
|
| |
| void | Add (TaskLambdaType task) |
| | Adds a task to the queue.
|
| |
| int32_t | GetSize () |
| | Get the number of tasks in the queue.
|
| |
Task queue with a thread pool.
◆ TaskLambdaType
Lambda function type to do a task.
◆ TaskQueue()
| tkrzw::TaskQueue::TaskQueue |
( |
| ) |
|
◆ ~TaskQueue()
| tkrzw::TaskQueue::~TaskQueue |
( |
| ) |
|
◆ Start()
| void tkrzw::TaskQueue::Start |
( |
int32_t | num_worker_threads | ) |
|
Starts worker threads.
- Parameters
-
| num_worker_threads | The number of worker threads. |
◆ Stop()
| void tkrzw::TaskQueue::Stop |
( |
double | timeout | ) |
|
Stops worker threads.
- Parameters
-
| timeout | The timeout in seconds to wait for all tasks in the queue to be done. |
◆ Add() [1/2]
| void tkrzw::TaskQueue::Add |
( |
std::unique_ptr< Task > | task | ) |
|
Adds a task to the queue.
- Parameters
-
◆ Add() [2/2]
Adds a task to the queue.
- Parameters
-
| task | The lambda function to do the task. |
◆ GetSize()
| int32_t tkrzw::TaskQueue::GetSize |
( |
| ) |
|
Get the number of tasks in the queue.
- Returns
- The number of tasks in the queue.