Open vCassius opened 8 months ago
Does the process appear to freeze after the first attempt? If so, then you are likely experiencing a deadlock. The docs for DashMap::remove()
says this:
Locking behaviour: May deadlock if called when holding any sort of reference into the map
In your case, you are holding a reference to m while also trying to remove that element. For something like this, consider using DashMap::retain()
instead.
// sleep(Duration::from_millis(10)).await;
message.retain(|key, value| {
println!("got key: {key} value: {value}");
false
});
As a side note, it is better to isolate your issue as a minimal reproducible example next time. The code above was quite a bit to unpack.
will fail to remove key when iter,i don't know why.