diff options
author | pixel <pixel> | 2008-02-18 09:55:08 +0000 |
---|---|---|
committer | pixel <pixel> | 2008-02-18 09:55:08 +0000 |
commit | 2677424e6dd5513b3fae9817214db41cc211a873 (patch) | |
tree | 0740a8115e7da6e548ea0eed4e2c48c778598bb5 /lib/Task.cc | |
parent | 60ee2d57d95314f00d110c70106115c577dbdafa (diff) |
Providing the 'Yield' method for tasks.
Diffstat (limited to 'lib/Task.cc')
-rw-r--r-- | lib/Task.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Task.cc b/lib/Task.cc index 0b19ab3..6493111 100644 --- a/lib/Task.cc +++ b/lib/Task.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Task.cc,v 1.33 2007-05-30 11:57:10 pixel Exp $ */ +/* $Id: Task.cc,v 1.34 2008-02-18 09:55:08 pixel Exp $ */ #ifndef _WIN32 #include <sys/time.h> @@ -31,7 +31,7 @@ #include "BString.h" #include "gettext.h" -Task::Task() : current(0), state(TASK_ON_HOLD), stopped(false), suspended(false), wbta(0), wta(0), BurstHandle(0) { +Task::Task() : current(0), state(TASK_ON_HOLD), stopped(false), suspended(false), yielded(false), wbta(0), wta(0), BurstHandle(0) { TaskMan::AddTask(this); } @@ -116,6 +116,20 @@ void Task::WaitFor(const timeval & t, int flags) { TaskMan::WaitFor(t, this, flags); } +void Task::Yield() { + yielded = true; + Suspend(TASK_ON_HOLD); +} + +bool Task::Yielded() { + return yielded; +} + +void Task::Unyield() { + yielded = false; + SetBurst(); +} + void Task::SetBurst() { state = TASK_BURST; } |