#include <task.h>
Public Member Functions | |
void | halt () |
Task () | |
Protected Member Functions | |
virtual void | doWork ()=0 |
virtual string | name () const =0 |
Private Member Functions | |
void | begin () |
virtual void | run () |
Private Attributes | |
unsigned | n |
unsigned | repeat |
Friends | |
void | fork (Task *t) |
void | repeat (Task *t, unsigned millis) |
abstraction around threads. simpler than BackgroundJob which is used behind the scenes. allocate the Task dynamically. when the thread terminates, the Task object will delete itself.
Definition at line 30 of file task.h.
mongo::task::Task::Task | ( | ) |
void mongo::task::Task::begin | ( | ) | [private] |
virtual void mongo::task::Task::doWork | ( | ) | [protected, pure virtual] |
Implemented in mongo::task::Server.
void mongo::task::Task::halt | ( | ) |
for a repeating task, stop after current invocation ends. can be called by other threads as long as the Task is still in scope.
virtual string mongo::task::Task::name | ( | ) | const [protected, pure virtual] |
Implements mongo::BackgroundJob.
Implemented in mongo::task::Server.
virtual void mongo::task::Task::run | ( | ) | [private, virtual] |
define this to do your work. after this returns, state is set to done. after this returns, deleted if deleteSelf true.
NOTE: if run() throws, the exception will be caught within 'this' object and will ultimately lead to the BackgroundJob's thread being finished, as if run() returned.
Implements mongo::BackgroundJob.
void fork | ( | Task * | t | ) | [friend] |
run once
run doWork() over and over, with a pause between runs of millis
unsigned mongo::task::Task::n [private] |
unsigned mongo::task::Task::repeat [private] |