I'm looking for a good non-blocking sleep timer in C for windows.
Currently I am using sleep(10);
which of course is a blocking timer.
Also I want it to consume no system resources, like my sleep timer it doesn't use any CPU or system resources which I am happy with.
So, what is the best non-blocking sleep timer I could use? And please also include an example of how to use it.
Thanks.
You dont need an API you need to change your design.
A simple one is this.
You can have multiple threads, One is the Manager Thread and other are Worker Threads. At every 10 seconds the manager thread will wake up create a new worker thread and go to sleep. The worker threads will keep working even when the Manager is sleeping and this you have your non blocking effects.
I dont know how familar you are with threads, but here is a very very basic tutorial, that might get you started with this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With