Page Speed Optimization Libraries  1.2.24.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends
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 InitiateShutDown ()
void WaitForShutDownComplete ()
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.

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

Starts the shutdown process, preventing further tasks from being queued. Does not wait for any active tasks to be completed. This must be followed by WaitForShutDownComplete. It is invalid to call InitiateShutDown() twice in a row.

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().

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

This must be called prior to creating sequences.

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.

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

Equivalent to "InitiateShutDown(); WaitForShutDownComplete();"

Blocks waiting for all outstanding tasks to be completed. Must be preceded by InitiateShutDown().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines