// Just calling stop should still clear all pending work MORDOR_UNITTEST(Scheduler, hijackStopOnScheduled) { Fiber::ptr doNothingFiber(new Fiber(&doNothing)); WorkerPool pool; MORDOR_TEST_ASSERT_EQUAL(Scheduler::getThis(), &pool); pool.schedule(doNothingFiber); MORDOR_TEST_ASSERT_EQUAL(doNothingFiber->state(), Fiber::INIT); pool.stop(); MORDOR_TEST_ASSERT_EQUAL(doNothingFiber->state(), Fiber::TERM); }
MORDOR_UNITTEST(Scheduler, tolerantException) { WorkerPool pool; pool.schedule(throwException); MORDOR_TEST_ASSERT_ANY_EXCEPTION(pool.stop()); }
// Stop can be called multiple times without consequence MORDOR_UNITTEST(Scheduler, idempotentStopHijack) { WorkerPool pool; pool.stop(); pool.stop(); }