How to do Rust equivalent of Java's ConcurrentLinkedQueue.poll()?

Is there a Rust-based way to implement the equivalent of Java's ConcurrentLinkedQueue.poll() function?

Is there a way to do it using the Crossbeam-channel crate?
Maybe a way using std?

If there is a way, please show it to me....

It sounds like you want a way to read from a channel, but instead of the read operation blocking until there is something in the channel, return immediately with a Option.

Have a look at the Receiver::try_recv() method from std::sync::mpsc.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.