diff options
author | Pixel <pixel@nobis-crew.org> | 2012-04-06 11:40:55 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2012-04-06 11:40:55 -0700 |
commit | f2cfa1707c713c7bb01d16f4c2c4d96803ea6793 (patch) | |
tree | a722f3ad52ec471520097c5bfbbf2ab8cb4e2603 /tests | |
parent | 7fbb819bf6f590bf2337d2277f77487ef7a5ce86 (diff) |
Making it simplier to register a task and wait for it. Also renamed createTask to registerTask, which makes way more sense.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-Http.cc | 6 | ||||
-rw-r--r-- | tests/test-Sockets.cc | 11 | ||||
-rw-r--r-- | tests/test-Tasks.cc | 4 |
3 files changed, 13 insertions, 8 deletions
diff --git a/tests/test-Http.cc b/tests/test-Http.cc index bd0ef49..f54fba0 100644 --- a/tests/test-Http.cc +++ b/tests/test-Http.cc @@ -118,10 +118,10 @@ void MainTask::Do() { yield(); waitFor(&event); - Task * stopper = new Stopper; - Events::TaskEvent stopperEvent(stopper); + + Events::TaskEvent stopperEvent; + Task * stopper = TaskMan::registerTask(new Stopper, &stopperEvent); waitFor(&stopperEvent); - TaskMan::createTask(stopper); bool gotEvent = false, gotStopperEvent = false; int count = 0; diff --git a/tests/test-Sockets.cc b/tests/test-Sockets.cc index c576c97..4ef0a78 100644 --- a/tests/test-Sockets.cc +++ b/tests/test-Sockets.cc @@ -62,11 +62,16 @@ void MainTask::Do() { Printer::enable(M_ALL); Printer::log(M_STATUS, "Test::Sockets running."); - Events::TaskEvent evtSvr(listener = TaskMan::createTask(new Listener<Worker>(1234))); - Events::TaskEvent evtCln(TaskMan::createTask(new Client)); - Printer::log(M_STATUS, "Created %s", listener->getName()); + Events::TaskEvent evtSvr; + Events::TaskEvent evtCln; + + listener = TaskMan::registerTask(new Listener<Worker>(1234), &evtSvr); + TaskMan::registerTask(new Client, &evtCln); + waitFor(&evtSvr); waitFor(&evtCln); + + Printer::log(M_STATUS, "Created %s", listener->getName()); bool svrDone = false, clnDone = false; while (!svrDone || !clnDone) { yield(); diff --git a/tests/test-Tasks.cc b/tests/test-Tasks.cc index 60d1dd3..da5346f 100644 --- a/tests/test-Tasks.cc +++ b/tests/test-Tasks.cc @@ -30,8 +30,8 @@ void MainTask::Do() { customPrinter = new CustomPrinter(); Printer::log(M_STATUS, "Test::Tasks running."); - Task * testTask = TaskMan::createTask(new TestTask()); - Events::TaskEvent taskEvt(testTask); + Events::TaskEvent taskEvt; + Task * testTask = TaskMan::registerTask(new TestTask(), &taskEvt); waitFor(&taskEvt); TAssert(!taskEvt.gotSignal()); yield(); |