MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / ensure_started

Method ensure_started

packages/server/src/simulators/session.rs:148–171  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

146 }
147
148 pub fn ensure_started(&self) -> Result<(), AppError> {
149 loop {
150 let mut state = self.inner.state.lock().unwrap();
151 match *state {
152 SessionState::Ready | SessionState::Streaming => return Ok(()),
153 SessionState::Attaching => {
154 drop(self.inner.start_condvar.wait(state).unwrap());
155 }
156 _ => {
157 *state = SessionState::Attaching;
158 break;
159 }
160 }
161 }
162
163 if let Err(error) = self.inner.native.start() {
164 *self.inner.state.lock().unwrap() = SessionState::Failed;
165 self.inner.start_condvar.notify_all();
166 return Err(error);
167 }
168 *self.inner.state.lock().unwrap() = SessionState::Ready;
169 self.inner.start_condvar.notify_all();
170 Ok(())
171 }
172
173 pub async fn ensure_started_async(&self) -> Result<(), AppError> {
174 let session = self.clone();

Callers 3

ensure_started_asyncMethod · 0.45
performance_log_eventsFunction · 0.45
simulator_logsFunction · 0.45

Calls 2

waitMethod · 0.80
startMethod · 0.65

Tested by

no test coverage detected