postmates / hopper

A Rust mpsc with unbounded members in bounded memory
Other
48 stars 7 forks source link

0.1.1 does _not_ maintain ordering #4

Closed blt closed 7 years ago

blt commented 7 years ago

hopper should maintain a FIFO ordering of inputs. This is something we've not been explicitly (!) testing. This ordering was broken by the optimizations that landed in 0.1.1. In particular, consider that the following test will fail:

mod integration {
    extern crate tempdir;
    extern crate hopper;

    use self::hopper::channel_with_max_bytes;

    #[test]
    fn large_sequence_comes_back_exactly() {
        let dir = tempdir::TempDir::new("hopper").unwrap();
        let (mut snd, mut rcv) =
            channel_with_max_bytes("zero_item_round_trip", dir.path(), 1_048_576).unwrap();

        assert_eq!(None, rcv.next());

        let max = 10_000;

        for i in 0..max {
            snd.send(i);
        }

        let mut nxt = 0;
        loop {
            match rcv.next() {
                Some(i) => {
                    assert_eq!(i, nxt);
                    nxt += 1;
                }
                None => break,
            }
        }
    }
}

I will yank 0.1.1.

/cc @pulltab @tsantero