Class TaskScheduler

Class Documentation

class TaskScheduler

Public Types

enum ShutDownPolicy

The generic states known to the data model.

Values:

enumerator SHUTDOWN_POLICY_WAIT

Wait for completion of remaining scheduled tasks on shutdown. Default.

enumerator SHUTDOWN_POLICY_CANCEL

Cancel enqued tasks and wait for completion of in-progress tasks.

Public Functions

virtual ~TaskScheduler()
virtual bool Submit(Task *task) = 0

Submit a job (task) to be run. This job may run on a different thread (there is no guarantee of running on separate threads, or on the calling thread — implementation- dependent).

Parameters

task -- Instance of Task interface. Must be a heap object. TaskScheduler takes ownership of the Task instance upon submission and will delete the Task instance once the Task has completed execution (specifically, any time after the Task::Run method returns).

Returns

True if task submission succeeded, false otherwise.

virtual void Shutdown() = 0

Stop the task scheduler. Will block until all busy threads are idle.

NOTE : For general use, prefer the static method

ShutdownInstance() over this instance method.

virtual void SetShutdownPolicy(ShutDownPolicy policy) = 0

Sets the behavior of TaskScheduler on shutdown.

Parameters

policy --

Public Static Functions

static TaskScheduler *GetInstance()

Get singleton TaskScheduler instance, creating the instance if necessary.

static void ShutdownInstance()

Stop the singleton TaskScheduler instance if GetInstance() has been previously called, otherwise noop.