diff options
author | David Robillard <d@drobilla.net> | 2012-05-14 06:18:58 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-14 06:18:58 +0000 |
commit | e8e347d61552be45d5db505a47b5ceec99149ca0 (patch) | |
tree | 55c7a956e9b61184e21fb29f207dc0d1f21b00cb /test | |
parent | 17cc5056bbd4c5e79ee16894f94892d5a11d521c (diff) | |
download | raul-e8e347d61552be45d5db505a47b5ceec99149ca0.tar.gz raul-e8e347d61552be45d5db505a47b5ceec99149ca0.tar.bz2 raul-e8e347d61552be45d5db505a47b5ceec99149ca0.zip |
Fully test Thread::set_scheduling().
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4414 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test')
-rw-r--r-- | test/thread_test.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/thread_test.cpp b/test/thread_test.cpp index 95bdb76..00539eb 100644 --- a/test/thread_test.cpp +++ b/test/thread_test.cpp @@ -16,6 +16,7 @@ #include <iostream> +#include "raul/log.hpp" #include "raul/AtomicInt.hpp" #include "raul/Semaphore.hpp" #include "raul/Thread.hpp" @@ -29,18 +30,24 @@ Raul::AtomicInt n_errors(0); class Waiter : public Raul::Thread { public: - Waiter(Semaphore& sem) : Raul::Thread("Waiter"), _sem(sem) {} + Waiter(Semaphore& sem) : Raul::Thread("Waiter"), _sem(sem) { + if (set_scheduling(true, 10)) { + Raul::warn << "Set priority on non-existent thread" << endl; + } + } private: void _run() { - set_scheduling(true, 10); + if (!set_scheduling(true, 10)) { + Raul::error << "Failed to set priority" << endl; + } var = 41; cout << "[Waiter] Waiting for signal..." << endl; _sem.wait(); cout << "[Waiter] Received signal, exiting" << endl; var = 42; if (var != 42) { - cerr << "[Waiter] error: var != 42" << endl; + Raul::error << "[Waiter] var != 42" << endl; ++n_errors; } } @@ -53,7 +60,7 @@ main() { Thread& main_thread = Thread::get("Main"); if (main_thread.name() != "Main") { - cerr << "error: Main thread name is not 'Main'" << endl; + Raul::error << "[Main] Thread name is not 'Main'" << endl; return 1; } @@ -72,7 +79,7 @@ main() cout << "[Main] Exiting" << endl; if (var != 24) { - cerr << "[Main] error: var != 24" << endl; + Raul::error << "[Main] var != 24" << endl; ++n_errors; } |