fn multishot_loom_recycle<F>(f: F)
    where
        F: FnOnce(Sender<i32>) + Send + Sync + Copy + 'static,
    {
        loom::model(move || {
            let test_waker = Arc::new(TestWaker::new());
            let waker = test_waker.clone().into();
            let mut cx = Context::from_waker(&waker);

            let (sender, mut receiver) = channel();

            {
                thread::spawn({
                    move || {
                        f(sender);
                    }
                });

                let mut fut = receiver.recv();
                let mut fut = Pin::new(&mut fut);

                // Poll up to twice.
                let res = fut.as_mut().poll(&mut cx);
                if res == Poll::Pending {
                    let res = fut.as_mut().poll(&mut cx);
                    if res == Poll::Pending {
                        return;
                    }
                }
            }

            // The future was polled to completion, meaning that the sender was
            // consumed and should be immediately recyclable.
            let sender = receiver
                .sender()
                .expect("Could not recycle the sender after it was consumed");

            // It's all downhill from here, just make sure the recycled sender
            // works correctly.
            {
                thread::spawn({
                    move || {
                        sender.send(13);
                    }
                });

                let mut fut = receiver.recv();
                let mut fut = Pin::new(&mut fut);

                let res = fut.as_mut().poll(&mut cx);
                if let Poll::Ready(val) = res {
                    assert_eq!(val, Ok(13));
                }
            }
        });
    }
// Executes a closure consuming the sender and attempts to reuse the
// channel.
Executes a closure consuming the sender and attempts to reuse the
channel.
Executes a closure consuming the sender and attempts to reuse the channel .
fn multishot_loom_recycle<F>(f: F)
    where
        F: FnOnce(Sender<i32>) + Send + Sync + Copy + 'static,
    {
        loom::model(move || {
            let test_waker = Arc::new(TestWaker::new());
            let waker = test_waker.clone().into();
            let mut cx = Context::from_waker(&waker);
            let (sender, mut receiver) = channel();
            {
                thread::spawn({
                    move || {
                        f(sender);
                    }
                });
                let mut fut = receiver.recv();
                let mut fut = Pin::new(&mut fut);
                // Poll up to twice.
                let res = fut.as_mut().poll(&mut cx);
                if res == Poll::Pending {
                    let res = fut.as_mut().poll(&mut cx);
                    if res == Poll::Pending {
                        return;
                    }
                }
            }
            // The future was polled to completion, meaning that the sender was
            // consumed and should be immediately recyclable.
            let sender = receiver
                .sender()
                .expect("Could not recycle the sender after it was consumed");
            // It's all downhill from here, just make sure the recycled sender
            // works correctly.
            {
                thread::spawn({
                    move || {
                        sender.send(13);
                    }
                });
                let mut fut = receiver.recv();
                let mut fut = Pin::new(&mut fut);
                let res = fut.as_mut().poll(&mut cx);
                if let Poll::Ready(val) = res {
                    assert_eq!(val, Ok(13));
                }
            }
        });
    }
fn multishot_loom_recycle < F > ( f : F ) where F : FnOnce ( Sender < i32 > ) + Send + Sync + Copy + ' static , { loom :: model ( move | | { let test_waker = Arc :: new ( TestWaker :: new ( ) ) ; let waker = test_waker . clone ( ) . into ( ) ; let mut cx = Context :: from_waker ( & waker ) ; let ( sender , mut receiver ) = channel ( ) ; { thread :: spawn ( { move | | { f ( sender ) ; } } ) ; let mut fut = receiver . recv ( ) ; let mut fut = Pin :: new ( & mut fut ) ; // Poll up to twice. let res = fut . as_mut ( ) . poll ( & mut cx ) ; if res == Poll :: Pending { let res = fut . as_mut ( ) . poll ( & mut cx ) ; if res == Poll :: Pending { return ; } } } // The future was polled to completion, meaning that the sender was // consumed and should be immediately recyclable. let sender = receiver . sender ( ) . expect ( " " ) ; // It's all downhill from here, just make sure the recycled sender // works correctly. { thread :: spawn ( { move | | { sender . send ( 13 ) ; } } ) ; let mut fut = receiver . recv ( ) ; let mut fut = Pin :: new ( & mut fut ) ; let res = fut . as_mut ( ) . poll ( & mut cx ) ; if let Poll :: Ready ( val ) = res { assert_eq ! ( val Ok ( 13 ) ) ; } } } ) ; }
Executes a closure consuming the sender and attempts to reuse the
channel.
Executes a closure consuming the sender and attempts to reuse the channel .
f
F