Skip to content
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

thread: Add mock versions of thread::park and Thread::unpark #240

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented 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

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 hawkw requested review from carllerche and Darksonn November 18, 2021 20:03
@hawkw hawkw merged commit d9eac1f into master Nov 22, 2021
@hawkw hawkw deleted the eliza/thread-park branch November 22, 2021 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose a loom version of std::thread::park
2 participants