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));