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

Function run_start_if_idle

packages/server/src/logs.rs:46–72  ·  view source on GitHub ↗
(
    state: &Arc<LogStreamState>,
    start: F,
)

Source from the content-addressed store, hash-verified

44}
45
46async fn run_start_if_idle<T, F, Fut>(
47 state: &Arc<LogStreamState>,
48 start: F,
49) -> Result<Option<T>, AppError>
50where
51 F: FnOnce() -> Fut,
52 Fut: Future<Output = Result<T, AppError>>,
53{
54 {
55 let mut status = state.status.lock().await;
56 if !matches!(status.phase, LogStreamPhase::Idle) {
57 return Ok(None);
58 }
59 status.phase = LogStreamPhase::Starting;
60 }
61
62 match start().await {
63 Ok(value) => {
64 state.status.lock().await.phase = LogStreamPhase::Running;
65 Ok(Some(value))
66 }
67 Err(error) => {
68 state.status.lock().await.phase = LogStreamPhase::Idle;
69 Err(error)
70 }
71 }
72}
73
74impl LogRegistry {
75 pub fn new() -> Self {

Calls 1

startFunction · 0.85

Tested by

no test coverage detected