0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Types | Private Attributes | Static Private Attributes | List of all members
Hypertable::MaintenanceQueue Class Reference

Queue for periodic maintenance work. More...

#include <MaintenanceQueue.h>

Collaboration diagram for Hypertable::MaintenanceQueue:
Collaboration graph
[legend]

Classes

struct  LtMaintenanceTask
 
class  MaintenanceQueueState
 
class  Worker
 

Public Member Functions

 MaintenanceQueue (int worker_count)
 Constructor to set up the maintenance queue. More...
 
void shutdown ()
 Shuts down the maintenance queue. More...
 
void join ()
 Waits for a shutdown to complete. More...
 
void stop ()
 Stops (suspends) queue processing. More...
 
void start ()
 Starts queue processing. More...
 
template<typename _Function >
void drop_range_tasks (_Function __f)
 Drops range maintenance tasks from the queue. More...
 
bool contains (Range *range)
 Returns true if queue contains a maintenance task for range. More...
 
void add (MaintenanceTask *task)
 Adds a maintenance task to the queue. More...
 
size_t size ()
 Returns the size of the queue. More...
 
int64_t generation ()
 Returns queue generation number. More...
 
bool full ()
 Returns true if any tasks are in queue or all worker threads are busy executing tasks. More...
 
bool empty ()
 Returns true if maintenance queue is empty. More...
 
void wait_for_empty ()
 Waits for queue to become empty. More...
 
bool wait_for_empty (ClockT::time_point deadline)
 Waits for queue to become empty with deadline. More...
 
int worker_count ()
 Returns the number of worker threads configured for the queue. More...
 

Private Types

typedef std::priority_queue
< MaintenanceTask
*, std::vector
< MaintenanceTask * >
, LtMaintenanceTask
TaskQueue
 

Private Attributes

MaintenanceQueueState m_state
 
ThreadGroup m_threads
 
int m_worker_count
 
bool joined
 

Static Private Attributes

static int ms_pause = 0
 
static std::condition_variable ms_cond
 

Detailed Description

Queue for periodic maintenance work.

Definition at line 55 of file MaintenanceQueue.h.

Member Typedef Documentation

typedef std::priority_queue<MaintenanceTask *, std::vector<MaintenanceTask *>, LtMaintenanceTask> Hypertable::MaintenanceQueue::TaskQueue
private

Definition at line 72 of file MaintenanceQueue.h.

Constructor & Destructor Documentation

Hypertable::MaintenanceQueue::MaintenanceQueue ( int  worker_count)
inline

Constructor to set up the maintenance queue.

It creates a number of worker threads specified by the worker_count argument.

Parameters
worker_countnumber of worker threads to create

Definition at line 233 of file MaintenanceQueue.h.

Member Function Documentation

void Hypertable::MaintenanceQueue::add ( MaintenanceTask task)
inline

Adds a maintenance task to the queue.

If the task has an associated range, then it adds the range to the MaintenanceQueueState::ranges set.

Parameters
taskMaintenance task to add

Definition at line 319 of file MaintenanceQueue.h.

bool Hypertable::MaintenanceQueue::contains ( Range range)
inline

Returns true if queue contains a maintenance task for range.

Parameters
rangePointer to Range object
Returns
true if queue contains a maintenance task for range, false otherwise.

Definition at line 310 of file MaintenanceQueue.h.

template<typename _Function >
void Hypertable::MaintenanceQueue::drop_range_tasks ( _Function  __f)
inline

Drops range maintenance tasks from the queue.

Template Parameters
_FunctionPredicate function accepting Range *
Parameters
__fUnary predicate function to determine which range tasks to drop

Definition at line 286 of file MaintenanceQueue.h.

bool Hypertable::MaintenanceQueue::empty ( )
inline

Returns true if maintenance queue is empty.

Returns
true if queue is empty, false otherwise

Definition at line 361 of file MaintenanceQueue.h.

bool Hypertable::MaintenanceQueue::full ( )
inline

Returns true if any tasks are in queue or all worker threads are busy executing tasks.

Returns
true if queue is full, false otherwise

Definition at line 352 of file MaintenanceQueue.h.

int64_t Hypertable::MaintenanceQueue::generation ( )
inline

Returns queue generation number.

When the queue is created, the generation number is initialized to zero. Each time a task is successfully excecuted and removed from the queue, the generation number is incremented by one.

Returns
Generation number

Definition at line 343 of file MaintenanceQueue.h.

void Hypertable::MaintenanceQueue::join ( )
inline

Waits for a shutdown to complete.

This method returns when all maintenance queue threads exit.

Definition at line 254 of file MaintenanceQueue.h.

void Hypertable::MaintenanceQueue::shutdown ( )
inline

Shuts down the maintenance queue.

All "in flight" requests are carried out and then all threads exit. join can be called to wait for completion of the shutdown.

Definition at line 246 of file MaintenanceQueue.h.

size_t Hypertable::MaintenanceQueue::size ( )
inline

Returns the size of the queue.

The size is computed as the queue size plus the number of tasks in flight.

Returns
Size of queue

Definition at line 332 of file MaintenanceQueue.h.

void Hypertable::MaintenanceQueue::start ( )
inline

Starts queue processing.

Definition at line 271 of file MaintenanceQueue.h.

void Hypertable::MaintenanceQueue::stop ( )
inline

Stops (suspends) queue processing.

Definition at line 263 of file MaintenanceQueue.h.

void Hypertable::MaintenanceQueue::wait_for_empty ( )
inline

Waits for queue to become empty.

Definition at line 368 of file MaintenanceQueue.h.

bool Hypertable::MaintenanceQueue::wait_for_empty ( ClockT::time_point  deadline)
inline

Waits for queue to become empty with deadline.

Parameters
deadlineReturn if queue not empty by this absolute time
Returns
true if queue empty, false if deadline reached

Definition at line 378 of file MaintenanceQueue.h.

int Hypertable::MaintenanceQueue::worker_count ( )
inline

Returns the number of worker threads configured for the queue.

Returns
Number of configured worker threads

Definition at line 387 of file MaintenanceQueue.h.

Member Data Documentation

bool Hypertable::MaintenanceQueue::joined
private

Definition at line 224 of file MaintenanceQueue.h.

MaintenanceQueueState Hypertable::MaintenanceQueue::m_state
private

Definition at line 221 of file MaintenanceQueue.h.

ThreadGroup Hypertable::MaintenanceQueue::m_threads
private

Definition at line 222 of file MaintenanceQueue.h.

int Hypertable::MaintenanceQueue::m_worker_count
private

Definition at line 223 of file MaintenanceQueue.h.

condition_variable Hypertable::MaintenanceQueue::ms_cond
staticprivate

Definition at line 58 of file MaintenanceQueue.h.

int Hypertable::MaintenanceQueue::ms_pause = 0
staticprivate

Definition at line 57 of file MaintenanceQueue.h.


The documentation for this class was generated from the following files: