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

Use per-mock mutexes in MockStore #36

Merged
merged 1 commit into from
Apr 1, 2021
Merged

Conversation

Wesmania
Copy link

This makes mocks no longer panic, while making sure that calling
individual mocked methods does not lock the entire mock. For
convenience, the mutex is moved inside MockStore.

Fixes #35.

Signed-off-by: Igor Kotrasinski [email protected]

This makes mocks no longer panic, while making sure that calling
individual mocked methods does not lock the entire mock. For
convenience, the mutex is moved inside MockStore.

Fixes nrxus#35.

Signed-off-by: Igor Kotrasinski <[email protected]>
@nrxus
Copy link
Owner

nrxus commented Apr 1, 2021

Ah thank you so much! This totally works!

I had forgotten that I had implemented an "Exhausted" state to the mocks so they didn't get "consumed" anymore, it is always just by &mut which lets you do the Mutex<Arc<Mock>>!

I will be merging this soon, I just want to make sure I fully grok it first (:

@nrxus nrxus merged commit 3f27234 into nrxus:master Apr 1, 2021
@nrxus
Copy link
Owner

nrxus commented Apr 1, 2021

I did some minor cosmetic tweaks to the tests, mostly for my own benefit for readability later (:

Thanks a lot!

@Wesmania Wesmania deleted the fix-mutex-panic branch April 1, 2021 07:57
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.

Mocks panic when accessed from multiple threads
2 participants