Closed novacrazy closed 1 year ago
Definitely possible. I'll implement them (+ any/any_async) next week.
In the meantime, you can try following if your code allows blocking code:
// No locks are acquired during iteration over entries, however `HashIndex` iterators cannot be sent across `awaits`.
hashindex.iter(&barrier).for_each(|(k, v)| {
if !retain_cond(k, v) {
// IT IS A BLOCKING METHOD; the corresponding bucket will be locked during entry removal.
hashindex.remove(k);
// Or, if you need to double-check the state the value with a lock acquired on the bucket,
// hashindex.remove_if(k, |v| !retain_cond(k, v));
}
}
Well, easier than I thought, though some code is repeated here and there (need to refactor the code once async_fn_in_trait
gets stabilized). I'll upload 1.6.2 in an hour.
Phenomenal response time! Hopefully I can get scc up and running in my server today.
Done (v1.6.2)! Hope that the new methods work as expected.
Would it be possible to implement
retain
/retain_async
onHashIndex
?Otherwise I'll have to use
HashMap
or iterate and create a list of keys to remove.