diff options
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(); |