NAME
A class of omni::chrono
MEMBERS
omni::chrono::async_timer
A class of omni::chrono
#include <omni/chrono/async_timer.hpp>
class omni::chrono::async_timer
MEMBERS
omni::chrono::async_timer::async_timer()
omni::chrono::async_timer::~async_timer()
bool omni::chrono::async_timer::auto_reset()
uint64_t omni::chrono::async_timer::hash()
uint32_t omni::chrono::async_timer::interval()
bool omni::chrono::async_timer::is_running()
void omni::chrono::async_timer::reset()
void omni::chrono::async_timer::set_auto_reset(bool autoreset)
void omni::chrono::async_timer::set_interval(uint32_t interval_ms)
void omni::chrono::async_timer::start()
void omni::chrono::async_timer::stop()
void omni::chrono::async_timer::swap(omni::chrono::async_timer& other)
inline omni::chrono::timer_sync_type::enum_t omni::chrono::async_timer::tick_type()
uint64_t omni::chrono::async_timer::type()
inline bool omni::chrono::async_timer::operator!=(const omni::chrono::async_timer& o)
omni::chrono::async_timer& omni::chrono::async_timer::operator=(const omni::chrono::async_timer& other)
bool omni::chrono::async_timer::operator==(const omni::chrono::async_timer& o)
omni::chrono::async_timer::disposing
omni::chrono::async_timer::name
omni::chrono::async_timer::state_object
omni::chrono::async_timer::tick
DESCRIPTION
This timer will invoke a
top
This timer will invoke a
tick
event at a specified interval regardless of how long the event delegate takes to complete. In other words, every time
the timer fires, a new thread is spawned invoking the attached delegate. If the timer is stopped before the interval has elapsed, no subsequent tick events will fire, however, any currently running tick events will finish.
top
NOTES
Since the timer event happens on a new thread, care must be taken to make sure the attached delegate is re-entrant. Additionally, you must be aware that it is possible to have 2 events fire simultaneously if the attached delegate executes for longer than the specified interval.
top
Since the timer event happens on a new thread, care must be taken to make sure the attached delegate is re-entrant. Additionally, you must be aware that it is possible to have 2 events fire simultaneously if the attached delegate executes for longer than the specified interval.
top
EXAMPLE
Visit the examples page for more.
top
#include <omnilib> static void timer_func(omni::chrono::tick_t tick, const omni::generic_ptr& so) { std::cout << "monotonic tick count = " << tick << std::endl; } int main(int argc, char* argv[]) { omni::chrono::async_timer timer(2000); timer.tick += timer_func; std::cout << "Starting the timer" << std::endl; timer.start(); omni::sync::sleep(6000); std::cout << "Stopping the timer" << std::endl; timer.stop(); return 0; }
top