-
Notifications
You must be signed in to change notification settings - Fork 141
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
feat req: try_insert
#245
Comments
How would you consolidate this with the
Alternatively, would using I'm thinking of something like match map.try_entry(key) {
None => error!("Skipped insert due to lock, key: {}", key),
Some(entry) => {
entry.and_modify(|e| e.0 = value.0).or_insert(value);
}
} |
Please implement this |
When debugging deadlocks one may want to get more insights and check if a key is locked before doing an insert. Currently this can be done with
A nicer approach with less boilerplate and no-deadlock guarantee could be:
Example use case:
When facing a deadlock and switching from
insert(k,v)
totry_insert(k,v)
as shown above and nokey
is repeatedly printed as locked it becomes unreasonable why the dead lock occurs at all (if the remaining code in the block does not interact with the map). Is that assumption right?The text was updated successfully, but these errors were encountered: