in MobiusCore/Source/AsyncStartStopStateMachine.swift [85:102]
func transitionToRunning(by transition: (StoppedState) throws -> RunningState) throws {
dispatchPrecondition(condition: .notOnQueue(queue))
try queue.sync {
switch snapshot() {
case .running:
throw Error.wrongState
case .stopped(let stoppedState):
rawState.value = .transitioningToRunning
do {
let runningState = try transition(stoppedState)
become(running: runningState)
} catch {
rawState.value = .stopped
throw error
}
}
}
}