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

Make Memory adapter threadsafe #702

Merged
merged 1 commit into from
Mar 9, 2023
Merged

Conversation

bkeepers
Copy link
Collaborator

@bkeepers bkeepers commented Mar 8, 2023

Addresses #699 (comment)

This uses Concurrent::Hash (which just uses Hash on MRI since any C function is thread safe and Hash is implemented in C) as the backend source for the memory adapter and replaces any non-threadsafe uses (like ||=).

See update

@bkeepers bkeepers force-pushed the threadsafe-memory branch from 8073cfd to 23ac86e Compare March 9, 2023 19:08
@bkeepers
Copy link
Collaborator Author

bkeepers commented Mar 9, 2023

Update: After experimenting Concurrent::Hash and several other classes from concurrent-ruby, I settled on just using a Mutex to wrap all adapter operations. It makes it a lot cleaner, and since this is all data in memory it should have minimal performance impact.

@bkeepers bkeepers force-pushed the threadsafe-memory branch 2 times, most recently from 8950d13 to 0d9fd1a Compare March 9, 2023 19:23
@bkeepers bkeepers force-pushed the threadsafe-memory branch from 0d9fd1a to 8622117 Compare March 9, 2023 19:58
@bkeepers bkeepers merged commit 06ceeb4 into poll-improvements Mar 9, 2023
@bkeepers bkeepers deleted the threadsafe-memory branch March 9, 2023 20:09
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.

1 participant