-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
I happened to create deadlocks accidentally by holding a reference into the DashMap across awaits, and came to think that maybe it might be possible to make an API that disallowed such use even by accident?
It looks like one way to do that is to bar all the work performed on the returned value behind a function, something like this:
pub fn process<Q, R, F: FnOnce(&T) -> R>(&'a self, key: &Q, f: F) -> R {
f(self.get(key))
}
pub fn process_mut<Q, R, F: FnOnce(&mut T) -> R>(&'a self, key: &Q, f: F) -> R {
f(self.get_mut(key))
}Is there a better way to do that? Maybe there's some way to opt-in to non-awaitable code without changes to DashMap by wrapping return value into something clever?
Is there a need for such API?
kennytmthedilletante, eareimu, raulescobar-g, taosx, LovelyZeeiam and 2 more
Metadata
Metadata
Assignees
Labels
No labels