/// Listens for presentation requests and schedules presents.
/// Connects to the Scenic event stream to listen for OnFramePresented messages and calls present
/// when Scenic is ready for an update.
Listens for presentation requests and schedules presents.
Connects to the Scenic event stream to listen for OnFramePresented messages and calls present
when Scenic is ready for an update.
Listens for presentation requests and schedules presents . Connects to the Scenic event stream to listen for OnFramePresented messages and calls present when Scenic is ready for an update .
pub fn start_presentation_loop(
    sender: PresentationSender,
    mut receiver: PresentationReceiver,
    weak_session: Weak<Mutex<scenic::Session>>,
) {
    fasync::Task::local(async move {
        let mut event_stream = {
            let session = weak_session.upgrade().expect("Failed to acquire session");
            let event_stream = session.lock().take_event_stream();
            event_stream
        };
        let mut present_requested = false;
        while let Some(message) = receiver.next().await {
            match message {
                PresentationMessage::RequestPresent => {
                    // Queue a present if not already queued.
                    if !present_requested {
                        sender
                            .unbounded_send(PresentationMessage::Present)
                            .expect("failed to send Present message");
                        present_requested = true;
                    }
                }
                PresentationMessage::Present => {
                    present_requested = false;
                    if let Some(session) = weak_session.upgrade() {
                        present(&session);
                        // Wait for frame to be presented before we queue another present.
                        while let Some(event) =
                            event_stream.try_next().await.expect("Failed to get next event")
                        {
                            match event {
                                ui_scenic::SessionEvent::OnFramePresented {
                                    frame_presented_info: _,
                                } => break,
                            }
                        }
                    } else {
                        break;
                    }
                }
            }
        }
    })
    .detach();
}
pub fn start_presentation_loop ( sender : PresentationSender , mut receiver : PresentationReceiver , weak_session : Weak < Mutex < scenic :: Session > > , ) { fasync :: Task :: local ( async move { let mut event_stream = { let session = weak_session . upgrade ( ) . expect ( " " ) ; let event_stream = session . lock ( ) . take_event_stream ( ) ; event_stream } ; let mut present_requested = false ; while let Some ( message ) = receiver . next ( ) . await { match message { PresentationMessage :: RequestPresent => { // Queue a present if not already queued. if ! present_requested { sender . unbounded_send ( PresentationMessage :: Present ) . expect ( " " ) ; present_requested = true ; } } PresentationMessage :: Present => { present_requested = false ; if let Some ( session ) = weak_session . upgrade ( ) { present ( & session ) ; // Wait for frame to be presented before we queue another present. while let Some ( event ) = event_stream . try_next ( ) . await . expect ( " " ) { match event { ui_scenic :: SessionEvent :: OnFramePresented { frame_presented_info : _ , } => break , } } } else { break ; } } } } } ) . detach ( ) ; }
Listens for presentation requests and schedules presents.
Listens for presentation requests and schedules presents .
sender
PresentationSender
receiver
PresentationReceiver
weak_session
Weak<Mutex<scenic::Session>>