0

I wrote a timercallback class that don't have enough speed in running.

class Manager
{
    ...
    void CallFunction(Function<Treturn>* m_function)
    {
        do
        {
            if (m_Status == TimerStatus::Paused)
            {
                unique_lock<mutex> lock(m_MutexLock);
                m_Notifier.wait(lock);
            }
            while (m_Status != TimerStatus::Stoped&&m_Status != TimerStatus::Paused)
            {
            unique_lock<mutex> lock(m_MutexLock);
                m_Notifier.wait_for(lock, m_Interval);

                (*m_function)();
            }

        } while (m_Status == TimerStatus::Paused);
    }
    ...
}

But when set time of timercallback to call function every 1ms don't call and take more for example 10 ms. I need help for improve code to call callback function (event function of this timer) in 1 ms and run in one thread with lock. How can I do this? sample of use this class:

Manager tester;
TimerCallback<microseconds> m_timer(chrono::microseconds(10),Core::Utility::ptr_fun(&tester,&Manager::runner));
  • First, what do you mean you need this code below 1ms? Which part? And second, you need way more context than this. Take a read of [mcve] – Passer By Jul 06 '17 at 12:59
  • Yes you're right @PasserBy. – Abbas Aliakbari Jul 06 '17 at 13:11
  • for explain problem : when set time of timercallback to call function every 1ms don't call and take more for example 10 ms. I need help for improve code to call callback function (event function of this timer) in 1 ms – Abbas Aliakbari Jul 06 '17 at 13:11

0 Answers0