Page Speed Optimization Libraries
1.13.35.1
|
#include "worker.h"
Public Member Functions | |
void | Start () |
Tries to start the work thread (if it hasn't been started already). | |
bool | IsBusy () |
void | ShutDown () |
void | set_queue_size_stat (Waveform *x) |
Protected Member Functions | |
Worker (StringPiece thread_name, ThreadSystem *runtime) | |
bool | QueueIfPermitted (Function *closure) |
virtual bool | IsPermitted (Function *closure)=0 |
int | NumJobs () |
Friends | |
class | WorkThread |
This class is a base for various mechanisms of running things in background.
If you just want to run something in background, you want to use a subclass of this, such as a SlowWorker or QueuedWorker instance.
Subclasses should implement bool PermitQueue() and provide an appropriate wrapper around QueueIfPermitted().
bool net_instaweb::Worker::IsBusy | ( | ) |
Returns true if there was a job running or any jobs queued at the time this function was called.
|
protectedpure virtual |
Subclasses should implement this method to implement the policy on whether to run given tasks or not.
|
protected |
Returns the number of jobs, including any running and queued jobs. The lock semantics here are as follows:
|
protected |
If IsPermitted() returns true, queues up the given closure to be run, takes ownership of closure, and returns true. (Also wakes up the work thread to actually run it if it's idle)
Otherwise it merely returns false, and doesn't do anything else.
|
inline |
Sets up a timed-variable statistic indicating the current queue depth.
This must be called prior to starting the thread.
void net_instaweb::Worker::ShutDown | ( | ) |
Finishes the currently running jobs, and deletes any queued jobs. No further jobs will be accepted after this call either; they will just be canceled. It is safe to call this method multiple times.