From 3cf44918b7d7f1cba6a71bdbe1ecb3742941b034 Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 13 Oct 2011 23:51:21 -0700 Subject: The tasks can now set themselves to be non-preemptible. Also implemented a mechanism to re-arm an event. --- tests/test-Tasks.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') 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."); } -- cgit v1.2.3