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/TaskMan.cc | |
parent | 60ee2d57d95314f00d110c70106115c577dbdafa (diff) |
Providing the 'Yield' method for tasks.
Diffstat (limited to 'lib/TaskMan.cc')
-rw-r--r-- | lib/TaskMan.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index 4cc7fd2..ee7958b 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: TaskMan.cc,v 1.53 2008-02-18 00:55:31 pixel Exp $ */ +/* $Id: TaskMan.cc,v 1.54 2008-02-18 09:55:08 pixel Exp $ */ #ifndef _WIN32 #include <signal.h> @@ -576,6 +576,22 @@ void TaskMan::MainLoop() throw (GeneralException) { } } + bool got_yield = false; + /* Switch all yielded tasks to burning state. */ + for (TaskList_t::iterator p = TaskList.begin(); p != TaskList.end(); p++) { + Task * t = *p; + + if (t->IsStopped()) { + continue; + } + + if (t->Yielded()) { + t->Unyield(); + } + + got_yield = true; + } + /* Let's compute the nearest timeout, and run a round trip for expired timeouts. */ int timeout = -1; event = Task::EVT_TIMEOUT; @@ -657,12 +673,14 @@ void TaskMan::MainLoop() throw (GeneralException) { p = w4ha.begin(); } } + + bool timeout_condition = no_burst && !Zombies.size() && !got_sigchild && !got_yield; #ifdef _WIN32 - r = poll(ufsd, nfds, (no_burst) && !(Zombies.size()) && !(got_sigchild) ? timeout: 0); + r = poll(ufsd, nfds, timeout_condition ? timeout: 0); #else sigprocmask(SIG_UNBLOCK, &sigchildset, 0); - r = poll(ufsd, nfds, (no_burst) && !(Zombies.size()) && !(got_sigchild) ? timeout: 0); + r = poll(ufsd, nfds, timeout_condition ? timeout: 0); sigprocmask(SIG_BLOCK, &sigchildset, 0); #endif CleanChildren(); |