A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../algorithm/../../cpp/../c/thread/thrd_sleep.html below:

thrd_sleep - cppreference.com

int thrd_sleep( const struct timespec* duration,
                struct timespec* remaining );

(since C11)

Blocks the execution of the current thread for at least until the TIME_UTC based duration pointed to by duration has elapsed.

The sleep may resume earlier if a signal that is not ignored is received. In such case, if remaining is not NULL, the remaining time duration is stored into the object pointed to by remaining.

[edit] Parameters duration - pointer to the duration to sleep for remaining - pointer to the object to put the remaining time on interruption. May be NULL, in which case it is ignored [edit] Return value

​0​ on successful sleep, -1 if a signal occurred, other negative value if an error occurred.

[edit] Notes

duration and remaining may point at the same object, which simplifies re-running the function after a signal.

The actual sleep time may be longer than requested because it is rounded up to the timer granularity and because of scheduling and context switching overhead.

The POSIX equivalent of this function is nanosleep.

[edit] Example

Output:

Time: Mon Feb  2 16:18:41 2015
Time: Mon Feb  2 16:18:42 2015
[edit] References
[edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4