MongoDB  2.7.0
Public Member Functions | Static Public Member Functions | List of all members
mongo::PeriodicTask Class Referenceabstract

these run "roughly" every minute instantiate statically class MyTask : public PeriodicTask { public: virtual std::string name() const { return "MyTask; " } virtual void doWork() { log() << "hi" << endl; } } myTask; More...

#include <background.h>

Inheritance diagram for mongo::PeriodicTask:
mongo::DBConnectionPool

Public Member Functions

virtual void taskDoWork ()=0
 
virtual std::string taskName () const =0
 

Static Public Member Functions

static void startRunningPeriodicTasks ()
 Starts the BackgroundJob that runs PeriodicTasks. More...
 
static Status stopRunningPeriodicTasks (int gracePeriodMillis)
 Waits 'gracePeriodMillis' for the BackgroundJob responsible for PeriodicTask execution to finish any running tasks, then destroys it. More...
 

Detailed Description

these run "roughly" every minute instantiate statically class MyTask : public PeriodicTask { public: virtual std::string name() const { return "MyTask; " } virtual void doWork() { log() << "hi" << endl; } } myTask;

Member Function Documentation

void mongo::PeriodicTask::startRunningPeriodicTasks ( )
static

Starts the BackgroundJob that runs PeriodicTasks.

You may call this multiple times, from multiple threads, and the BackgroundJob will be started only once. Please note that since this method starts threads, it is not appropriate to call it from within a mongo initializer. Calling this method after calling 'stopRunningPeriodicTasks' does not re-start the background job.

Status mongo::PeriodicTask::stopRunningPeriodicTasks ( int  gracePeriodMillis)
static

Waits 'gracePeriodMillis' for the BackgroundJob responsible for PeriodicTask execution to finish any running tasks, then destroys it.

If the BackgroundJob was never started, returns Status::OK right away. If the BackgroundJob does not terminate within the grace period, returns an invalid status. It is safe to call this method repeatedly from one thread if the grace period is overshot. It is not safe to call this method from multiple threads, or in a way that races with 'startRunningPeriodicTasks'.


The documentation for this class was generated from the following files: