Task queue device.
More...
#include <kcthread.h>
List of all members.
Classes |
| class | Task |
| | Interface of a task. More...
|
| class | WorkerThread |
| | Implementation of the worker thread.
|
Public Member Functions |
| | TaskQueue () |
| | Default Constructor.
|
| virtual | ~TaskQueue () |
| | Destructor.
|
| virtual void | do_task (Task *task)=0 |
| | Process a task.
|
| virtual void | do_start (const Task *task) |
| | Process the starting event.
|
| virtual void | do_finish (const Task *task) |
| | Process the finishing event.
|
| void | start (size_t thnum) |
| | Start the task queue.
|
| void | finish () |
| | Finish the task queue.
|
| int64_t | add_task (Task *task) |
| | Add a task.
|
| int64_t | count () |
| | Get the number of tasks in the queue.
|
Detailed Description
Constructor & Destructor Documentation
Member Function Documentation
Process a task.
- Parameters:
-
Process the starting event.
- Parameters:
-
- Note:
- This is called for each thread on starting.
Process the finishing event.
- Parameters:
-
- Note:
- This is called for each thread on finishing.
Start the task queue.
- Parameters:
-
| thnum | the number of worker threads. |
Finish the task queue.
- Note:
- This function blocks until all tasks in the queue are popped.
Add a task.
- Parameters:
-
- Returns:
- the number of tasks in the queue.
Get the number of tasks in the queue.
- Returns:
- the number of tasks in the queue.