/// Assign new task to the thread void assignNewTask(Threadpool::Task* task) { m_mutex.lock(); ANKI_ASSERT(m_task == nullptr && "Probably forgot to wait for tasks"); m_task = task; m_mutex.unlock(); m_condVar.notifyOne(); // Wake the thread }
/** Starts the ticks generation. You can use this member function even when timer is running (to restart it). */ void Timer::start() { // start/create timer thread (if this is the first Timer started) Timer::start_timer_thread(); { ScopedLock hold(timer_mutex); if (!m_running) { // add timer timers.push_back(this); m_running = true; } m_firstTick = true; m_timeCounter = m_interval; m_tickCounter = 0; // wake up timer thread wakeup_condition.notifyOne(); } }
/** Stops the timer_thread (called from ~Application()). @internal */ void Timer::stop_timer_thread() { Thread* thrd = NULL; { ScopedLock hold(timer_mutex); if (timer_thread == NULL) return; thrd = timer_thread; timer_thread = NULL; timer_break = true; wakeup_condition.notifyOne(); } thrd->join(); delete thrd; thrd = NULL; }