/// Binds to the component instance in the given realm, starting it if it's not
/// already running. Returns the list of child realms whose instances need to be eagerly started
/// after this function returns. The caller is responsible for calling
/// bind_eager_children_recursive themselves to ensure eager children are recursively binded.
Binds to the component instance in the given realm, starting it if it's not
already running. Returns the list of child realms whose instances need to be eagerly started
after this function returns. The caller is responsible for calling
bind_eager_children_recursive themselves to ensure eager children are recursively binded.
Binds to the component instance in the given realm starting it if it ' s not already running . Returns the list of child realms whose instances need to be eagerly started after this function returns . The caller is responsible for calling bind_eager_children_recursive themselves to ensure eager children are recursively binded .
async fn bind_instance<'a>(&'a self, realm: Arc<Realm>) -> Result<Vec<Arc<Realm>>, ModelError> {
        // There can only be one task manipulating an instance's execution at a time.
        let mut started = false;
        let mut state = await!(realm.instance.state.lock());
        match state.execution {
            Some(_) => {}
            None => {
                let component =
                    await!(realm.resolver_registry.resolve(&realm.instance.component_url))?;
                state.populate_decl(component.decl, &*realm)?;
                let decl = state.decl.as_ref().unwrap();
                if decl.program.is_some() {
                    let (outgoing_dir_client, outgoing_dir_server) = zx::Channel::create()
                        .map_err(|e| ModelError::namespace_creation_failed(e))?;
                    let mut namespace = IncomingNamespace::new(component.package)?;
                    let ns = await!(namespace.populate(self.clone(), &realm.abs_moniker, decl))?;
                    let execution = Execution::start_from(
                        component.resolved_url,
                        namespace,
                        DirectoryProxy::from_channel(
                            fasync::Channel::from_channel(outgoing_dir_client).unwrap(),
                        ),
                    )?;
                    let start_info = fsys::ComponentStartInfo {
                        resolved_url: Some(execution.resolved_url.clone()),
                        program: data::clone_option_dictionary(&decl.program),
                        ns: Some(ns),
                        outgoing_dir: Some(ServerEnd::new(outgoing_dir_server)),
                    };
                    await!(realm.default_runner.start(start_info))?;
                    state.execution = Some(execution);
                }
                started = true;
            }
        }
        // Return children that need eager starting.
        let mut eager_children = vec![];
        if started {
            for child_realm in state.child_realms.as_ref().unwrap().values() {
                match child_realm.instance.startup {
                    fsys::StartupMode::Eager => {
                        eager_children.push(child_realm.clone());
                    }
                    fsys::StartupMode::Lazy => {}
                }
            }
        }
        Ok(eager_children)
    }
async fn bind_instance < ' a > ( & ' a self , realm : Arc < Realm > ) -> Result < Vec < Arc < Realm > > , ModelError > { // There can only be one task manipulating an instance's execution at a time. let mut started = false ; let mut state = await ! ( realm instance state lock ( ) ) ; match state . execution { Some ( _ ) => { } None => { let component = await ! ( realm resolver_registry resolve ( realm instance component_url ) ) ? ; state . populate_decl ( component . decl , & * realm ) ? ; let decl = state . decl . as_ref ( ) . unwrap ( ) ; if decl . program . is_some ( ) { let ( outgoing_dir_client , outgoing_dir_server ) = zx :: Channel :: create ( ) . map_err ( | e | ModelError :: namespace_creation_failed ( e ) ) ? ; let mut namespace = IncomingNamespace :: new ( component . package ) ? ; let ns = await ! ( namespace populate ( self clone ( ) realm abs_moniker decl ) ) ? ; let execution = Execution :: start_from ( component . resolved_url , namespace , DirectoryProxy :: from_channel ( fasync :: Channel :: from_channel ( outgoing_dir_client ) . unwrap ( ) , ) , ) ? ; let start_info = fsys :: ComponentStartInfo { resolved_url : Some ( execution . resolved_url . clone ( ) ) , program : data :: clone_option_dictionary ( & decl . program ) , ns : Some ( ns ) , outgoing_dir : Some ( ServerEnd :: new ( outgoing_dir_server ) ) , } ; await ! ( realm default_runner start ( start_info ) ) ? ; state . execution = Some ( execution ) ; } started = true ; } } // Return children that need eager starting. let mut eager_children = vec ! [ ] ; if started { for child_realm in state . child_realms . as_ref ( ) . unwrap ( ) . values ( ) { match child_realm . instance . startup { fsys :: StartupMode :: Eager => { eager_children . push ( child_realm . clone ( ) ) ; } fsys :: StartupMode :: Lazy => { } } } } Ok ( eager_children ) }
Binds to the component instance in the given realm, starting it if it's not
already running.
Binds to the component instance in the given realm starting it if it ' s not already running .
&'a self
realm
Arc<Realm>