net_instaweb::QueuedWorkerPool Class Reference

#include "queued_worker_pool.h"

List of all members.

Classes

class  Sequence

Public Types

typedef std::set< Sequence * > SequenceSet

Public Member Functions

 QueuedWorkerPool (int max_workers, ThreadSystem *thread_system)
SequenceNewSequence ()
 Returns NULL if shutting down.
void FreeSequence (Sequence *sequence)
void ShutDown ()
void SetLoadSheddingThreshold (int x)
void set_queue_size_stat (Waveform *x)

Static Public Member Functions

static bool AreBusy (const SequenceSet &sequences)

Static Public Attributes

static const int kNoLoadShedding = -1

Friends

class Sequence

Detailed Description

Maintains a predefined number of worker threads, and dispatches any number of groups of sequential tasks to those threads.


Member Function Documentation

static bool net_instaweb::QueuedWorkerPool::AreBusy ( const SequenceSet &  sequences  )  [static]

Returns true if any of the given sequences is busy. Note that multiple sequences are checked atomically; otherwise we could end up missing work. For example, consider if we had a sequence for main rewrite work, and an another one for expensive work. In this case, if we tried to check their busyness independently, the following could happen: 1) First portion of inexpensive work is done, so we queue up some on expensive work thread. 2) We check whether inexpensive work sequence is busy. It's not. 3) The expensive work runs, finishes, and queues up more inexpensive work. 4) We check whether expensive sequence is busy. It's not, so we would conclude we quiesced --- while there was still work in the inexpensive queue.

void net_instaweb::QueuedWorkerPool::FreeSequence ( Sequence sequence  ) 

Shuts down a sequence and frees it. This does *not* block waiting for the Sequence to finish.

Sequence* net_instaweb::QueuedWorkerPool::NewSequence (  ) 

Returns NULL if shutting down.

Sequence is owned by the pool, and will be automatically freed when the pool is finally freed (e.g. on server shutdown). But the sequence does *not* auto-destruct when complete; it must be explicitly freed using FreeSequence().

void net_instaweb::QueuedWorkerPool::set_queue_size_stat ( Waveform x  )  [inline]

Sets up a timed-variable statistic indicating the current queue depth.

This must be called prior to creating sequences.

void net_instaweb::QueuedWorkerPool::SetLoadSheddingThreshold ( int  x  ) 

If x == kNoLoadShedding disables load-shedding. Otherwise, if more than x sequences are queued waiting to run, sequences will start getting dropped and canceled, with oldest sequences canceled first.

Precondition: x > 0 || x == kNoLoadShedding x = kNoLoadShedding (the default) disables the limit.

Should be called before starting any work.

void net_instaweb::QueuedWorkerPool::ShutDown (  ) 

Shuts down all Sequences and Worker threads, but does not delete the sequences. The sequences will be deleted when the pool is destructed.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Tue May 29 16:34:15 2012 for Page Speed Optimization Libraries by  doxygen 1.6.3