amethyst / hibitset

Hierarchical bit set container
Other
117 stars 32 forks source link

Atomic drain set #17

Open zakarumych opened 6 years ago

zakarumych commented 6 years ago

It would be cool to have an BitSetLike which supports add_atomic as AtomicBItSet do but also drain_atomic which will unset all set bits yield their ids. Implementation should be similar to AtomicBItSet except of using Ordering::Release in add_atomic. While draining it should swap mask with 0 using Ordering::Acquire and move to the next level for each bit set (yield at lowest level).

zakarumych commented 6 years ago

I need this for efficient implementation of futures::executor::Notify

kvark commented 6 years ago

We could have the ordering known to AtomicBitSet and just have different constructors for different order guarantee, without creating a new type and duplicating code.

zakarumych commented 6 years ago

@kvark wouldn't it slow down execution? If ordering is statically known compiler may remove all unused match arms and so mathing itself.| If we could put it into type level. By trait with associated const...

kvark commented 6 years ago

Hmm, that might be the case. Associated const sounds good to me.

torkleyy commented 6 years ago

@omni-viral Do you still need this?

zakarumych commented 6 years ago

I don't need it now. But it may be useful for those who use futures.