summaryrefslogtreecommitdiff
path: root/src/TaskMan.cc
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-10 19:36:55 -0700
committerPixel <pixel@nobis-crew.org>2011-10-10 19:36:55 -0700
commit965148b43b5b859934b7af2e8447ba1026a43a19 (patch)
tree290ff60cd1ebc9a065109620b2e9a5ff4e5b3d17 /src/TaskMan.cc
parentcf9a801ebcb4df0a8b1ea75e58ca8ea8960ba13b (diff)
Adding the basic "Handle" structure, and adding an early version of Input.
Renamed suspend() to yield(). Fixed a couple of bugs, and reorganized slightly some code.
Diffstat (limited to 'src/TaskMan.cc')
-rw-r--r--src/TaskMan.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/TaskMan.cc b/src/TaskMan.cc
index fd0246f..ea9c0fb 100644
--- a/src/TaskMan.cc
+++ b/src/TaskMan.cc
@@ -29,15 +29,24 @@ void Balau::TaskMan::mainLoop() {
taskList_t::iterator iL;
taskHash_t::iterator iH;
Task * t;
+ bool noWait = false;
- // checking "STARTING" tasks, and running them once
+ // checking "STARTING" tasks, and running them once; also try to build the status of the noWait boolean.
for (iH = m_tasks.begin(); iH != m_tasks.end(); iH++) {
t = *iH;
- if (t->getStatus() == Task::STARTING)
+ if (t->getStatus() == Task::STARTING) {
t->switchTo();
+ if ((t->getStatus() == Task::STOPPED) || (t->getStatus() == Task::FAULTED))
+ noWait = true;
+ }
}
- ev_run(m_loop, EVRUN_ONCE);
+ // probably means we have pending tasks; or none at all, for some reason. Don't wait on it forever.
+ if (!noWait && m_tasks.size() == 0)
+ noWait = true;
+
+ // libev's event "loop". We always runs it once though.
+ ev_run(m_loop, noWait ? EVRUN_NOWAIT : EVRUN_ONCE);
// let's check who got signaled, and call them
for (iH = m_signaledTasks.begin(); iH != m_signaledTasks.end(); iH++) {