rumqtt
rumqtt copied to clipboard
Is waiting on multiple channels with tokio::select! can skip messages or not?
By select! documentation it is stated, that it waits for the first future to succeed and drops all other futures.
And I wonder whether waiting on multiple receivers with poll in a loop is safe, or I might loose some messages because of it (i.e. whether waiting on a receiver is cancellation safe).
Do you mean calling eventloop.poll on multiple branches of select!?
I think it would be easier to answer if you can provide more context on whats your usecase for it.
@sushi-shi We'll check and get back to you cancellation safety
Hi, did you come to a conclusion if the future returned by .poll() is cancellation safe? I would use poll() with tokio::select! if it is. Reviewing the code, I think the critical part is in Eventloop::select(). Because this function uses select! internally, I assume that each branch there should be cancel safe, meaning that the whole Eventloop::select() function is cancel safe. Am I right? Would be nice to add this to the documentation of Eventloop::poll()
I would also like to know if .poll() on an EventLoop instance is cancel safe. Thanks!