-
-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace usleep with C++11's sleep_for #201
base: master
Are you sure you want to change the base?
Conversation
Build failure seems unrelated. |
Rebased. |
usleep is deprecated and replaced by nanosleep in POSIX 2008. sleep_for is standard C++11 and internally uses nanosleep.
Add this as a member function to |
On further evaluation, these should use condition variables, no? |
@@ -60,7 +61,7 @@ thread_base::stop_thread_wait() { | |||
release_global_lock(); | |||
|
|||
while (!is_inactive()) { | |||
usleep(1000); | |||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like average thread join. Sleeping for join is anti-pattern in userspace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
usleep is deprecated and replaced by nanosleep in POSIX 2008.
sleep_for is standard C++11 and internally uses nanosleep.