Skip to content

Non blocking timers for C++ (setInterval, setTimeout, etc)

Notifications You must be signed in to change notification settings

hypercore-cxx/timers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SYNOPSIS

Non blocking timers for C++.

USAGE

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

TEST

build run test

API

TIMEOUT

Hyper::Util::Timeout t;

t.start([&] {
  // timer called!
}, 1000);

TIMEOUT

Hyper::Util::Timeout t;

t.start([&] {
  // called after 1000ms.
}, 1000);

To clear a timeout use the clear() method.

t.clear();

INTERVAL

Hyper::Util::Interval i;

i.start([]() {
  // called every 1000ms.
}, 1000);

To clear an interval use the clear() method.

i.clear();

SLEEP

Put the current thread to sleep n for milliseconds.

Hyper::Util::sleep(100);

TIMER

Hyper::Util::Timer t; // starts the timer.

cout << "Milliseconds: " << t.ms(); // milliseconds since created.

t.reset(); // reset the timer.

About

Non blocking timers for C++ (setInterval, setTimeout, etc)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages