-
Notifications
You must be signed in to change notification settings - Fork 111
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
Expose a loom version of std::thread::park #133
Comments
I believe |
If so, maybe an alias can be created? It's much easier to conditionally import |
hawkw
added a commit
that referenced
this issue
Nov 18, 2021
Currently, `loom`'s mock version of `std::thread` does not provide mocked `std::thread::park` or `std::thread::Thread::unpark` APIs. It would be nice to be able to use `loom` to test implementations of synchronization primitives, and other code which uses `thread::park` and `Thread::unpark`. Fortunately, the `loom::rt` internals already contain the necessary primitives to provide simulated versions of these APIs --- they're used internally in the implementation of the mocked `Condvar` and `Notify` types. This branch adds APIs for simulating `thread::park` and `Thread::unpark`. Closes #133
hawkw
added a commit
that referenced
this issue
Nov 22, 2021
Currently, `loom`'s mock version of `std::thread` does not provide mocked `std::thread::park` or `std::thread::Thread::unpark` APIs. It would be nice to be able to use `loom` to test implementations of synchronization primitives, and other code which uses `thread::park` and `Thread::unpark`. Fortunately, the `loom::rt` internals already contain the necessary primitives to provide simulated versions of these APIs --- they're used internally in the implementation of the mocked `Condvar` and `Notify` types. This branch adds APIs for simulating `thread::park` and `Thread::unpark`. Closes #133
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a library that uses
std::thread::park()
andThread::unpark()
for parking one thread when it must wait for another thread to reach a certain point. These tests deadlock underloom
. I assume simply because the execution order it's currently evaluating demand that the thread waiting inpark()
make progress, and not the other ones. And this will obviously never happen.I have currently gotten the tests to pass by conditionally replacing
std::thread::park()
withloom::thread::yield_now()
. However, I'm not fully sure this tests what I want it to test 🤔Since I don't know anything about
loom
internals etc I will put it like this: Would it make sense to exposeloom::thread::park
and potentially a correspondingloom::thread::Thread
?The text was updated successfully, but these errors were encountered: