-
Notifications
You must be signed in to change notification settings - Fork 153
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
RFC: support "soft" synchronization for Async Runtime #289
Comments
I've came across same problem, it would be nice that dashmap can be run in async runtime |
Would love to see this! |
You should check if moka or quick-cache would fit your use-case. They are cache implementations, but you either a) should use cache in the first place, or b) can set the capacity to |
It's worth noting that I'm currently switching back from |
I'm looking into this at the moment. Hopefully I will have a satisfactory solution relatively soon. |
Background
Due to
DashMap
's usability and great work of dealing with racing condition, I have seen cases when it was used in production scenario, which also includes when async runtime are started (such as Tokio) and CRUD method ofDashMap
are called in Async Runtime.Problem
The
spin
or elsepark
behavior will block the current thread, if it was called in one of the async runtime's thread, the current async runtime thread will be blocked, which is not the best practice. (The task should yield the occupation of the current thread and let the current thread be able to handle other tasks).In the worst case, when all threads of async runtime are blocked due to waiting for some lock, none of the left async tasks are able to be executed.
Recommendations
Add feature flag such as
async_runtime
, when it was opened, use RwLock struct which can return struct that implements the Future trait whenread()
,write()
is called, such astokio::sync::RwLock
to replace theRwLock
in currentshards
type:dashmap/src/lib.rs
Line 90 in febc45d
The text was updated successfully, but these errors were encountered: