summaryrefslogtreecommitdiff
path: root/tests/test-Tasks.cc
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-13 23:51:21 -0700
committerPixel <pixel@nobis-crew.org>2011-10-14 00:00:22 -0700
commit3cf44918b7d7f1cba6a71bdbe1ecb3742941b034 (patch)
tree25ec6024a30df838fc0236548ca2a89815796c22 /tests/test-Tasks.cc
parent9704c57c47dc31f592ecf3a38e303ee3bcbbae74 (diff)
The tasks can now set themselves to be non-preemptible. Also implemented a mechanism to re-arm an event.
Diffstat (limited to 'tests/test-Tasks.cc')
-rw-r--r--tests/test-Tasks.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test-Tasks.cc b/tests/test-Tasks.cc
index 1faa194..bdafa8d 100644
--- a/tests/test-Tasks.cc
+++ b/tests/test-Tasks.cc
@@ -22,6 +22,12 @@ class TestTask : public Task {
}
};
+static void yieldingFunction() {
+ Events::Timeout timeout(0.2);
+ Task::yield(&timeout);
+ Assert(timeout.gotSignal());
+}
+
void MainTask::Do() {
customPrinter = new CustomPrinter();
Printer::log(M_STATUS, "Test::Tasks running.");
@@ -39,6 +45,15 @@ void MainTask::Do() {
yield();
Assert(timeout.gotSignal());
+ timeout.set(0.1);
+ timeout.reset();
+ setPreemptible(false);
+ yieldingFunction();
+ Assert(!timeout.gotSignal());
+ waitFor(&timeout);
+ yield();
+ Assert(timeout.gotSignal());
+
Printer::log(M_STATUS, "Test::Tasks passed.");
Printer::log(M_DEBUG, "You shouldn't see that message.");
}