fn poll(me: &Arc<Package>) {
            loop {
                match me.notified.replace(State::Polling) {
                    // We received a notification while previously polling, or
                    // this is the initial poll. We've got work to do below!
                    State::Notified => {}

                    // We've gone through this loop once and no notification was
                    // received while we were executing work. That means we got
                    // `NotReady` below and we're scheduled to receive a
                    // notification. Block ourselves and wait for later.
                    //
                    // When the notification comes in it'll notify our task, see
                    // our `Waiting` state, and resume the polling process
                    State::Polling => {
                        me.notified.set(State::Waiting(me.clone()));
                        break;
                    }

                    State::Waiting(_) => panic!("shouldn't see waiting state!"),
                }

                let (val, f) = match me.spawn.borrow_mut().poll_future_notify(me, 0) {
                    // If the future is ready, immediately call the
                    // resolve/reject callback and then return as we're done.
                    Ok(Async::Ready(value)) => (value, &me.resolve),
                    Err(value) => (value, &me.reject),

                    // Otherwise keep going in our loop, if we weren't notified
                    // we'll break out and start waiting.
                    Ok(Async::NotReady) => continue,
                };

                drop(f.call1(&JsValue::undefined(), &val));
                break;
            }
        }
// Move the future contained in `me` as far forward as we can. This will
// do as much synchronous work as possible to complete the future,
// ensuring that when it blocks we're scheduled to get notified via some
// callback somewhere at some point (vague, right?)
//
// TODO: this probably shouldn't do as much synchronous work as possible
//       as it can starve other computations. Rather it should instead
//       yield every so often with something like `setTimeout` with the
//       timeout set to zero.
Move the future contained in `me` as far forward as we can. This will
do as much synchronous work as possible to complete the future,
ensuring that when it blocks we're scheduled to get notified via some
callback somewhere at some point (vague, right?)

this probably shouldn't do as much synchronous work as possible
as it can starve other computations. Rather it should instead
yield every so often with something like `setTimeout` with the
timeout set to zero.
Move the future contained in ` me ` as far forward as we can . This will do as much synchronous work as possible to complete the future ensuring that when it blocks we ' re scheduled to get notified via some callback somewhere at some point ( vague right? ) this probably shouldn ' t do as much synchronous work as possible as it can starve other computations . Rather it should instead yield every so often with something like ` setTimeout ` with the timeout set to zero .
fn poll(me: &Arc<Package>) {
            loop {
                match me.notified.replace(State::Polling) {
                    // We received a notification while previously polling, or
                    // this is the initial poll. We've got work to do below!
                    State::Notified => {}
                    // We've gone through this loop once and no notification was
                    // received while we were executing work. That means we got
                    // `NotReady` below and we're scheduled to receive a
                    // notification. Block ourselves and wait for later.
                    //
                    // When the notification comes in it'll notify our task, see
                    // our `Waiting` state, and resume the polling process
                    State::Polling => {
                        me.notified.set(State::Waiting(me.clone()));
                        break;
                    }
                    State::Waiting(_) => panic!("shouldn't see waiting state!"),
                }
                let (val, f) = match me.spawn.borrow_mut().poll_future_notify(me, 0) {
                    // If the future is ready, immediately call the
                    // resolve/reject callback and then return as we're done.
                    Ok(Async::Ready(value)) => (value, &me.resolve),
                    Err(value) => (value, &me.reject),
                    // Otherwise keep going in our loop, if we weren't notified
                    // we'll break out and start waiting.
                    Ok(Async::NotReady) => continue,
                };
                drop(f.call1(&JsValue::undefined(), &val));
                break;
            }
        }
fn poll ( me : & Arc < Package > ) { loop { match me . notified . replace ( State :: Polling ) { // We received a notification while previously polling, or // this is the initial poll. We've got work to do below! State :: Notified => { } // We've gone through this loop once and no notification was // received while we were executing work. That means we got // `NotReady` below and we're scheduled to receive a // notification. Block ourselves and wait for later. // // When the notification comes in it'll notify our task, see // our `Waiting` state, and resume the polling process State :: Polling => { me . notified . set ( State :: Waiting ( me . clone ( ) ) ) ; break ; } State :: Waiting ( _ ) => panic ! ( " " ) , } let ( val , f ) = match me . spawn . borrow_mut ( ) . poll_future_notify ( me , 0 ) { // If the future is ready, immediately call the // resolve/reject callback and then return as we're done. Ok ( Async :: Ready ( value ) ) => ( value , & me . resolve ) , Err ( value ) => ( value , & me . reject ) , // Otherwise keep going in our loop, if we weren't notified // we'll break out and start waiting. Ok ( Async :: NotReady ) => continue , } ; drop ( f . call1 ( & JsValue :: undefined ( ) , & val ) ) ; break ; } }
Move the future contained in `me` as far forward as we can.
Move the future contained in ` me ` as far forward as we can .
me
&Arc<Package>
me
&Arc<Package>