summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-14 08:52:01 -0700
committerPixel <pixel@nobis-crew.org>2011-10-14 08:52:01 -0700
commit20124b259c408a3ad4427df5176553298907106c (patch)
tree968d0521577a66da5805fe1a5a2f27f6ca7ded19 /src
parent4a792414fbc28e81a4742cb916c0f8cfe2c4b6cf (diff)
Tweaking the Task class a bit.
-) setPreemptible now returns the previous state -) Events may now not have an owner -) Events may now have a callback (even though it still needs an owner to get into the ev_loop, for these kind of watchers...) TODO: -) think about a way to start a watcher without requireing a Task -) add a few more things in the Tasks unit tests
Diffstat (limited to 'src')
-rw-r--r--src/Task.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Task.cc b/src/Task.cc
index 938b3de..f7645e6 100644
--- a/src/Task.cc
+++ b/src/Task.cc
@@ -80,13 +80,15 @@ void Balau::Task::waitFor(Balau::Events::BaseEvent * e, bool override) {
m_loop = loop;
}
-void Balau::Task::setPreemptible(bool enable) {
+bool Balau::Task::setPreemptible(bool enable) {
+ bool wasPreemptible = !m_loop;
if (!m_loop && !enable) {
m_loop = ev_loop_new(EVFLAG_AUTO);
} else if (m_loop) {
ev_loop_destroy(m_loop);
m_loop = NULL;
}
+ return wasPreemptible;
}
struct ev_loop * Balau::Task::getLoop() {
@@ -98,7 +100,10 @@ struct ev_loop * Balau::Task::getLoop() {
void Balau::Events::BaseEvent::doSignal() {
m_signal = true;
- m_task->getTaskMan()->signalTask(m_task);
+ if (m_cb)
+ m_cb->gotEvent(this);
+ if (m_task)
+ m_task->getTaskMan()->signalTask(m_task);
}
Balau::Events::TaskEvent::TaskEvent(Task * taskWaited) : m_taskWaited(taskWaited) {