summaryrefslogtreecommitdiff
path: root/tests/test-Threads.cc
blob: 8e0817ddccf873189866324308bb0cd9102d055e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <Main.h>
#include <Threads.h>

using namespace Balau;

volatile bool threadWorked = false;

class TestThread : public Thread {
    virtual void * proc();
};

void * TestThread::proc() {
    Printer::log(M_STATUS, "Into a thread");
    threadWorked = true;
    return NULL;
}

void MainTask::Do() {
    Printer::log(M_STATUS, "Test::Threads running.");

    TestThread * t = new TestThread();
    Printer::log(M_STATUS, "Starting thread");
    t->threadStart();
    Printer::log(M_STATUS, "Joining thread");
    t->join();
    Printer::log(M_STATUS, "Deleting thread");
    delete t;

    TAssert(threadWorked);

    Printer::log(M_STATUS, "Test::Threads passed.");
}