karoo::exepool Class Reference

An exepool is a convenient way to run things asynchronously in a number of threads. More...

#include <queue.h>

Inheritance diagram for karoo::exepool:

karoo::referable

List of all members.

Public Member Functions

 exepool (int alloc_size, long granularity=5, int time_sample_alloc_size=100)
virtual ~exepool ()
 Destroy the pool.
void cleanupLater (exeque *q)
 Add a queue to the auto-cleanup list.
void cleanupAutoDeletes (bool force)
 Make sure the auto-deleted pools are cleaned up and stopped.
void setLogger (const log &logger)
 Set the logger object.
void stop (bool block=false)
bool isStopped (long wait_usec=0) const
int getImminentCount (unsigned usecs=0) const
 Get the number of pebbles that are scheduled and imminent to run.
void add (pebble *p)
void add (const struct timespec &ts, pebble *p)
void add (int after_seconds, pebble *p)
const poolstats & getStats (poolstats &ps, bool reset=false) const
int getSize () const

Protected Attributes

long granularity
int time_sample_alloc_size
int alloc_size
int size
exequefeed
exeque ** qs
log logger
karoo_mutex auto_sem
list< exeque * > auto_scheduled
list< exeque * > auto_stopped

Friends

class poolpebble


Detailed Description

An exepool is a convenient way to run things asynchronously in a number of threads.

You can add as many pebbles (task objects) to the exeque as you like, and they will be executed pretty much in the order you added them, though not strictly synchronously. You can also add then with a timestamp set in the future. Then they will be executed after that date.


Constructor & Destructor Documentation

virtual karoo::exepool::~exepool (  )  [virtual]

Destroy the pool.

Note that it is very important to call exepool::stop(true) before destroying the queue, to avoid race conditions.


Member Function Documentation

void karoo::exepool::cleanupAutoDeletes ( bool  force  ) 

Make sure the auto-deleted pools are cleaned up and stopped.

This method blocks until it has completed this cleanup.

void karoo::exepool::cleanupLater ( exeque q  ) 

Add a queue to the auto-cleanup list.

The queue will be deleted at a later date.

int karoo::exepool::getImminentCount ( unsigned  usecs = 0  )  const

Get the number of pebbles that are scheduled and imminent to run.

Parameters:
usecs the number of microseconds (of waiting pebbles) to consider as "imminent"

void karoo::exepool::setLogger ( const log &  logger  ) 

Set the logger object.

Parameters:
logger the log object for sending warninfs, errors etc... to


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

Generated on Tue Feb 16 15:04:29 2010 for Karoo by  doxygen 1.5.8