Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a sleep() function for Android NDK?

Under Android NDK, is there a sleep() function which sleeps for X miliseconds, but do not block the event loop?

We are writing API tests to work on Mac, Windows, and Android. So far, we have implemented some sort of sleep() for Mac and Windows, but we are all new to Android NDK and need some help there. Thank you in advance.

like image 232
Hai Vu Avatar asked Nov 29 '10 21:11

Hai Vu


People also ask

What can I do with Android NDK?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.

Is there a sleep function in C++?

Sleep () FunctionC++ language does not provide a sleep function of its own. However, the operating system's specific files like unistd. h for Linux and Windows. h for Windows provide this functionality.


1 Answers

Turning @mreichelt commment into an answer:

Yes there is a sleep(seconds) function.

  1. Add #include <unistd.h>

  2. Call: sleep(seconds) or usleep(microseconds)

note: A microsecond (us or Greek letter mu plus s) is one millionth (10 -6 ) of a second, while a millisecond (ms or msec) is one thousandth of a second

like image 126
kc ochibili Avatar answered Oct 15 '22 03:10

kc ochibili