Add monotonic time support with np pthread_cond_timedwait for Android and Apple#412
Open
vvydria wants to merge 1 commit intoboostorg:developfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improvements.
Android and Apple support none-portable functions for monotonic pthread cond wait.
Apple supports
pthread_cond_timedwait_relative_npsince macos(10.4) and ios(2.0): https://github.com/apple/darwin-libpthread/blob/main/include/pthread/pthread.h#L532Android up to
__ANDROID_API__ < 21supportspthread_cond_timedwait_monotonic_npandpthread_cond_timedwait_relative_np.Note that in some versions of the NDK, these symbols were removed from the header file(https://android.googlesource.com/platform/bionic/+/refs/heads/ndk-r13-release/libc/include/pthread.h) although they were present in the libc.map( https://android.googlesource.com/platform/bionic/+/refs/heads/ndk-r13-release/libc/libc.map.txt#779) and cpp(https://android.googlesource.com/platform/bionic/+/refs/heads/ndk-r13-release/libc/bionic/pthread_cond.cpp#221).
A workaround is to declare these functions as follows:
extern "C" int pthread_cond_timedwait_[monotonic|relative]_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);See related comments on this: https://android.googlesource.com/platform/bionic.git/+/refs/heads/ndk-release-r16/libc/include/pthread.h#162
Thank you !