C++ simple timer/tick function -


As the title says, I want to create a simple timer / tick function, which gives a 5 minute example I can call another function, the timer starts again again but without using the sleep or clock function. So what is a function or method, is an example counted for example above or below the second? Thanks for your help.

Although you said that you want to avoid "clock function", count 5 minutes without clock How to View

  • Result : The foo () method is called every 5 minutes.


      #include & lt; Thread & gt; # Include & lt; Iostream & gt; Zero foo () {std :: cout & lt; & Lt; "Hello! \ N"; } Int main () {std :: thread ([& amp;] {while (true) {// wait 5 min std :: this_thread :: sleep_for (std :: chrono :: minutes (5)); // our Call method foo ();}}) Apart (); // execution continues ... std :: cin.get ();   Note:  

    • I passed a lambda on the yarn but any obligation would do this.
    • is full of great stuff to manipulate the date and time, you can easily tune your timer with it.

  • Comments

    Popular posts from this blog

    java - org.apache.http.ProtocolException: Target host is not specified -

    java - Gradle dependencies: compile project by relative path -

    ruby on rails - Object doesn't support #inspect when used with .include -