# kyotocabinet::TaskQueue Class Reference

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

Task queue device.

## Constructor & Destructor Documentation

kyotocabinet::TaskQueue::TaskQueue | ( |  | ) |

Default Constructor.

virtual kyotocabinet::TaskQueue::~TaskQueue | ( |  | ) | `[virtual]`

Destructor.

## Member Function Documentation

virtual void kyotocabinet::TaskQueue::do_task | ( | Task * | task | ) | `[pure virtual]`

Process a task.

Parameters:

  task | a task object.

virtual void kyotocabinet::TaskQueue::do_start | ( | const Task * | task | ) | `[virtual]`

Process the starting event.

Parameters:

  task | a task object.

Note:
  This is called for each thread on starting.

virtual void kyotocabinet::TaskQueue::do_finish | ( | const Task * | task | ) | `[virtual]`

Process the finishing event.

Parameters:

  task | a task object.

Note:
  This is called for each thread on finishing.

void kyotocabinet::TaskQueue::start | ( | size_t | thnum | ) |

Start the task queue.

Parameters:

  thnum | the number of worker threads.

void kyotocabinet::TaskQueue::finish | ( |  | ) |

Finish the task queue.

Note:
  This function blocks until all tasks in the queue are popped.

int64_t kyotocabinet::TaskQueue::add_task | ( | Task * | task | ) |

Add a task.

Parameters:

  task | a task object.

Returns:
  the number of tasks in the queue.

int64_t kyotocabinet::TaskQueue::count | ( |  | ) |

Get the number of tasks in the queue.

Returns:
  the number of tasks in the queue.