Thread::sleep improvement: use nanosleep when available for higher resolution and be aware that usleep is not able to sleep longer than one second