Search code examples
rustchannelrust-tokiompsc

rust tokio::sync::mpsc::channel is_empty() returning false when len() returns 0


I have a tokio::sync::mpsc::channel open and the receiver's is_empty() method is returning false when len() method is returning 0. This only happens after 32 loops. Weird. Anyone have ideas on why this might be happening?


Solution

  • This is a bug, I have opened an issue on the tokio project.

    Like I said there, channels internally use blocks of 32 values, so this may explain why this happens every 32 sends.

    Edit: a correction has already been posted