diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-06-04 19:43:20 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-06-04 19:43:20 +0000 |
commit | 58a0a70fb2f13a04886038744feb5d26715de8f6 (patch) | |
tree | fa717aefc9bef5b1a3fbdd85393d402db40ee270 /libcxx/src | |
parent | be7eaddc69d06fee3c55bc10c34144c35895e2b0 (diff) | |
download | bcm5719-llvm-58a0a70fb2f13a04886038744feb5d26715de8f6.tar.gz bcm5719-llvm-58a0a70fb2f13a04886038744feb5d26715de8f6.zip |
Handle partial nanosleeps in this_thread::sleep_for
Signals may result in nanosleep returning with only some of the
requested sleeping performed.
Utilize nanosleep's "time-remaining" out parameter to continue sleeping
when this occurs.
llvm-svn: 210210
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/thread.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp index bd2b7c39238..e6f57c46a7d 100644 --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -121,7 +121,9 @@ sleep_for(const chrono::nanoseconds& ns) ts.tv_sec = ts_sec_max; ts.tv_nsec = giga::num - 1; } - nanosleep(&ts, 0); + + while (nanosleep(&ts, &ts) == -1 && errno == EINTR) + ; } } |