See file comment. More...
#include "queued_worker.h"
Public Member Functions | |
QueuedWorker (ThreadSystem *runtime) | |
virtual | ~QueuedWorker () |
This waits for the running task to terminate. | |
void | RunInWorkThread (Function *closure) |
void | TimedWait (ThreadSystem::Condvar *condvar, int64 timeout_ms) |
See file comment.
net_instaweb::QueuedWorker::QueuedWorker | ( | ThreadSystem * | runtime | ) | [explicit] |
Initializes the worker. You still need to call ->Start to actually start the thread, however. (Note: start can return false on failure).
void net_instaweb::QueuedWorker::RunInWorkThread | ( | Function * | closure | ) |
Runs the given closure in the work thread. Not that it's possible for the closure to be deleted without running in case where the system is shutting down.
Takes ownership of the closure.
void net_instaweb::QueuedWorker::TimedWait | ( | ThreadSystem::Condvar * | condvar, | |
int64 | timeout_ms | |||
) |
Issue a TimedWait on the specified condition variable. In a mock-time world, this queues a time-advancement closure on the worker, and then blocks waiting for the work-queue to be drained.