tsc_QuickTask

This class should be used for running minor tasks that run quickly, such as the periodic flushing of a buffer to disk, or polling a communications channel.

To use this class, subclass tsc_QuickTask and implement the TaskMain() function. TaskMain must not call any function that waits or performs UI. tsc_QuickTask can not be copied, and may only be passed by reference.

The tsc_QuickTask instance must continue to exist until the task has finished.

Public methods

tsc_QuickTask (const char* name);
Constructs a QuickTask. Supply a short descriptive name for use in logging and error messages.

void RunOnce (double delay = 0.0);
Runs the TaskMain function once after the given time in seconds. RunOnce() returns immediately.

void StartTimer (double period);
Runs the TaskMain function periodically on a worker thread. The period is in seconds and typically has a resolution of 0.001 seconds. StartTimer() returns immediately.

void StopTimer ();
Stops a periodic task if it is running on a timer.  This will prevent the next execution but will not stop a currently executing TaskMain.

virtual void TaskMain () = 0;
Main function of the quick task to be run. Because all work done in this function is run from the same shared pool of threads as other QuickTasks, do not call any function that waits or processes for more than a few hundred milliseconds, and do not perform UI. 

virtual ~tsc_QuickTask();
Destruction of the tsc_QuickTask instance will stop the task.