-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
POSIX threads corrections & enhancements #6944
Conversation
- Pass the returned errnum to `Errno.new`. - Fix `Thread::Mutex.try_lock` to return true when the lock was acquired and false otherwise. - Add a spec for `Thread.current`.
Prevents deadlocks and undefined mutex behavior. > A thread attempting to relock this mutex without first > unlocking it shall return with an error. A thread attempting > to unlock a mutex which another thread has locked shall > return with an error. A thread attempting to unlock an > unlocked mutex shall return with an error. > > http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_mutexattr_settype.html
6b8a295
to
54d3217
Compare
|
Configures thread condition variables to use the monotonic clock. Adds an overload for `#wait` that takes a timeout and executes the block when the timeout is reached, but doesn't when the condition variable is normally resumed. Refactors & enables Thread::ConditionVariable specs so they don't randomly hang.
54d3217
to
41045d6
Compare
Commits have been reordered, but since their sha didn't change, GitHub failed to notice it. |
@ysbaddaden the sha not changing is impossible... |
@@ -1,90 +1,89 @@ | |||
require "spec" | |||
|
|||
# These specs are marked as pending until we add | |||
# support for parallelism, where we'll see if we | |||
# need condition variables. |
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.
Since these were pending until somebody works on parallelism, and nobody did that yet, is it worth uncommenting these?
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.
Who said "nobody's working on MT" :)
But sure, I can keep the note.
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.
Oh, I meant all the specs. But if "somebody" ;-) is working on it, then this is fine.
Well, I have no idea why github doesn't understand reordered commits, then 😕 |
A collection of corrections and small enhancements to POSIX threads integration:
Fixes:
errno
;Thread::Mutex#try_lock
report whether the lock was acquired or not;Features:
Thread::ConditionVariable#wait
;Thread.yield
to pass CPU time to another thread.