wvwwvwwv / scalable-concurrent-containers

High performance containers and utilities for concurrent and asynchronous programming
Apache License 2.0
353 stars 17 forks source link

[Request] Async polling methods for Bag #169

Open CR7273868 opened 6 days ago

CR7273868 commented 6 days ago

Bag is all about pushing and popping. Having non blocking methods would make it more niche to put it in a while let Some(_) = bag.pop() {} loop.

CR7273868 commented 6 days ago

Same could be suggested for Stack & Queue

wvwwvwwv commented 6 days ago

Hi @CR7273868,

Can you elaborate on the request? Bag, Stack, and Queue are all completely non-blocking and lock-free, so an asynchronous method won't be needed.

Does "Async polling" mean a polling method returning true when there is an entry available? (like in typical channel data structures)

CR7273868 commented 6 days ago

Hi @CR7273868,

Can you elaborate on the request? Bag, Stack, and Queue are all completely non-blocking and lock-free, so an asynchronous method won't be needed.

Does "Async polling" mean a polling method returning true when there is an entry available? (like in typical channel data structures)

Yes, exactly like polling for available items and then when something is available that it extracts. This might also prevent the need for Option if I'm not wrong if ur checking the length (that's what I'm doing right now).

wvwwvwwv commented 6 days ago

That's an interesting idea, and it will be possible to implement something like,

async fn poll(&self) -> T {
  ...
}

async fn timed_poll(&self, timeout: Duration) -> Option<T> {
  ...
}