16#include <CArcBaseDllMain.h>
47 if ( pTimer !=
nullptr )
49 pTimer->start<T>( std::ref( fnCallback ), tDuration );
69 void start( std::function<
void(
void )> fnCallBack,
const T& tDuration )
71 m_fnCallBack = std::move( fnCallBack );
73 std::cout <<
"NEW TIMER (START) - ED!" << std::endl;
75 std::unique_ptr<std::thread> pThread(
new std::thread( [ &,
this ]()
79 if ( this->m_bCancel ) { std::cout <<
"TIMER (START) cancelled 1" << std::endl;
return; }
81 auto start = std::chrono::high_resolution_clock::now();
83 while ( !this->m_bCancel )
85 auto now = std::chrono::high_resolution_clock::now();
87 if ( std::chrono::duration_cast< T >( now - start ) >= tDuration )
93 if ( this->m_bCancel ) { std::cout <<
"TIMER (START) cancelled 2" << std::endl;
return; }
95 if ( m_fnCallBack !=
nullptr )
102 std::cout <<
"FUNCTION CLALBACK (START) is nullptr!" << std::endl;
107 std::cout <<
"TIMER (START) completed!" << std::endl;
114 std::function<void(
void)> m_fnCallBack;
static arc::gen4::CArcTimer * create(std::function< void(void)> fnCallback, const T &tDuration)
void cancel(void) noexcept