omni::chrono::async_timer::start
NAME

omni::chrono::async_timer::start

A member function of omni::chrono::async_timer

#include <omni/chrono/async_timer.hpp>
void omni::chrono::async_timer::start()


OVERLOADS

void omni::chrono::async_timer::start(uint32_t delay)

SYNOPSIS

Starts the timer.

top

DESCRIPTION

Starts the timer and blocks until the timer is in a running state. If the timer is already running, nothing happens.

top

ERRORS

omni::exceptions::invalid_delegate can be raised if there is no delegate attached to the tick event. Additionally omni::exceptions::index_out_of_range can be raised if the interval is set to 0.

top


EXAMPLE

#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;
}
Visit the examples page for more.

top