More work on tangibleCharacter, especially thread synch stuff

This commit is contained in:
2024-02-13 16:49:58 -05:00
parent d11fbca815
commit abb967f20b
7 changed files with 121 additions and 69 deletions

View File

@@ -11,15 +11,13 @@
// * You have a function to run in the background.
// * It should start the instant a foreground thread says "NOW".
// * It should be run exactly once for each "NOW".
// * The foreground thread eventually waits for the background thread to finish.
//
// To use this class, construct an FTriggeredTask,
// and provide a runnable object. The runnable
// object's "Run" method will get executed in
// each time you call 'Trigger' on the FTriggeredTask.
//
// The run method will never get called reentrantly,
// even if you call 'Trigger' rapidly in succession.
//
///////////////////////////////////////////////
class FTriggeredTask : public FRunnable
@@ -43,7 +41,12 @@ private:
// once. But if ThreadStopRequested is true, it means we
// want the thread to exit.
//
FEvent* ThreadEvent;
FEvent* CallEvent;
// This event is used when the thread is done
// with its work.
//
FEvent* ReturnEvent;
// The client whose task we're triggering.
//
@@ -91,12 +94,18 @@ public:
// Trigger
//
// Run the client's 'RUN' method once, in the
// background. Trigger is a no-op if the system
// is shut down. If you trigger when the task
// is already running, a trigger may get dropped.
// background.
//
void Trigger();
// Wait
//
// Wait for the background task to finish its work.
// If the background thread isn't running, then this
// returns immediately.
//
void Wait();
// IsRunning
//
bool IsRunning();