mongo::task::Task Class Reference

#include <task.h>

Inheritance diagram for mongo::task::Task:
Inheritance graph
[legend]

List of all members.

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)

Detailed Description

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.


Constructor & Destructor Documentation

mongo::task::Task::Task (  ) 

Member Function Documentation

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.


Friends And Related Function Documentation

void fork ( Task t  )  [friend]

run once

void repeat ( Task t,
unsigned  millis 
) [friend]

run doWork() over and over, with a pause between runs of millis


Member Data Documentation

unsigned mongo::task::Task::n [private]

Definition at line 42 of file task.h.

unsigned mongo::task::Task::repeat [private]

Definition at line 42 of file task.h.


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


mongodb
Author(s): Nate Koenig
autogenerated on Fri Jan 11 12:15:59 2013