From 8e68eb1dcd984e046e6fd674f9db1ac60ebec4b0 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 22 Oct 2008 19:12:33 +0000 Subject: [PATCH] is_alive() --- panda/src/event/asyncTask.I | 25 +++++++++++++++++++++++++ panda/src/event/asyncTask.h | 1 + 2 files changed, 26 insertions(+) diff --git a/panda/src/event/asyncTask.I b/panda/src/event/asyncTask.I index 53bdafe9fe..38e80a4f14 100644 --- a/panda/src/event/asyncTask.I +++ b/panda/src/event/asyncTask.I @@ -23,6 +23,31 @@ get_state() const { return _state; } +//////////////////////////////////////////////////////////////////// +// Function: AsyncTask::is_alive +// Access: Published +// Description: Returns true if the task is currently active or +// sleeping on some task chain, meaning that it will be +// executed in its turn, or false if it is not active. +// If the task has recently been removed while it is in +// the middle of execution, this will return false, +// because the task will not run again once it finishes. +//////////////////////////////////////////////////////////////////// +INLINE bool AsyncTask:: +is_alive() const { + switch (_state) { + case S_active: + case S_servicing: + case S_sleeping: + case S_active_nested: + return true; + + case S_inactive: + case S_servicing_removed: + return false; + } +} + //////////////////////////////////////////////////////////////////// // Function: AsyncTask::get_manager // Access: Published diff --git a/panda/src/event/asyncTask.h b/panda/src/event/asyncTask.h index 4c310e3c6f..9d881001dc 100644 --- a/panda/src/event/asyncTask.h +++ b/panda/src/event/asyncTask.h @@ -69,6 +69,7 @@ PUBLISHED: }; INLINE State get_state() const; + INLINE bool is_alive() const; INLINE AsyncTaskManager *get_manager() const; void remove();