Non blocking timers for C++
.
This module is designed to work with the datcxx
build tool. To add this
module to your project us the following command...
build add datcxx/timers
build run test
Hyper::Util::Timeout t;
t.start([&] {
// timer called!
}, 1000);
Hyper::Util::Timeout t;
t.start([&] {
// called after 1000ms.
}, 1000);
To clear a timeout use the clear()
method.
t.clear();
Hyper::Util::Interval i;
i.start([]() {
// called every 1000ms.
}, 1000);
To clear an interval use the clear()
method.
i.clear();
Put the current thread to sleep n for milliseconds.
Hyper::Util::sleep(100);
Hyper::Util::Timer t; // starts the timer.
cout << "Milliseconds: " << t.ms(); // milliseconds since created.
t.reset(); // reset the timer.