diff options
author | David Robillard <d@drobilla.net> | 2012-05-14 05:45:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-14 05:45:15 +0000 |
commit | ff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50 (patch) | |
tree | a66a97f7f842caa51ee6891d2f5037b6707c6784 /test | |
parent | 79deafe642561936ebb3bbcf585f2c6f26b456d3 (diff) | |
download | raul-ff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50.tar.gz raul-ff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50.tar.bz2 raul-ff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50.zip |
Clean up Thread interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4411 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test')
-rw-r--r-- | test/queue_test.cpp | 22 | ||||
-rw-r--r-- | test/sem_test.cpp | 6 | ||||
-rw-r--r-- | test/thread_test.cpp | 6 |
3 files changed, 16 insertions, 18 deletions
diff --git a/test/queue_test.cpp b/test/queue_test.cpp index 8685f15..e4ad230 100644 --- a/test/queue_test.cpp +++ b/test/queue_test.cpp @@ -14,17 +14,20 @@ along with Raul. If not, see <http://www.gnu.org/licenses/>. */ +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> + +#include <algorithm> #include <iostream> #include <string> #include <vector> -#include <algorithm> -#include <stdio.h> -#include <stdlib.h> -#include <limits.h> -#include "raul/SRSWQueue.hpp" + +#include "raul/AtomicInt.hpp" #include "raul/SRMWQueue.hpp" +#include "raul/SRSWQueue.hpp" #include "raul/Thread.hpp" -#include "raul/AtomicInt.hpp" +#include "raul/log.hpp" using namespace std; using namespace Raul; @@ -59,6 +62,9 @@ struct WriteAction { SRMWQueue<WriteAction> queue(QUEUE_SIZE); class WriteThread : public Thread { +public: + WriteThread(const std::string& name) : Thread(name) {} + protected: void _run() { while (true) { @@ -140,10 +146,10 @@ main() } cout << "Testing concurrent reading/writing" << endl; - vector<WriteThread*> writers(NUM_WRITERS, new WriteThread()); + vector<WriteThread*> writers(NUM_WRITERS, NULL); for (unsigned i=0; i < NUM_WRITERS; ++i) { - writers[i]->set_name(string("Writer ") + static_cast<char>('0' + i)); + writers[i] = new WriteThread((Raul::fmt("Writer %1%") % i).str()); writers[i]->start(); } diff --git a/test/sem_test.cpp b/test/sem_test.cpp index f3ed065..f8b0741 100644 --- a/test/sem_test.cpp +++ b/test/sem_test.cpp @@ -24,8 +24,7 @@ using namespace Raul; class Waiter : public Raul::Thread { public: - Waiter(Semaphore& sem) : _sem(sem) { - Thread::set_name("Waiter"); + Waiter(Semaphore& sem) : Raul::Thread("Waiter"), _sem(sem) { } private: @@ -47,9 +46,6 @@ private: int main() { - Thread& this_thread = Thread::get(); - this_thread.set_name("Main"); - Semaphore sem(0); Waiter waiter(sem); waiter.start(); diff --git a/test/thread_test.cpp b/test/thread_test.cpp index 738b30c..b74db72 100644 --- a/test/thread_test.cpp +++ b/test/thread_test.cpp @@ -23,8 +23,7 @@ using namespace Raul; class Waiter : public Raul::Thread { public: - Waiter(Semaphore& sem) : _sem(sem) { - Thread::set_name("Waiter"); + Waiter(Semaphore& sem) : Raul::Thread("Waiter"), _sem(sem) { } private: @@ -40,9 +39,6 @@ private: int main() { - Thread& this_thread = Thread::get(); - this_thread.set_name("Main"); - Semaphore sem(0); Waiter waiter(sem); waiter.start(); |