// // SDLAsyncTimerStream.swift // Tun // // Created by 安礼成 on 2026/2/3. // import Foundation class SDLAsyncTimerStream { let timer: DispatchSourceTimer init() { self.timer = DispatchSource.makeTimerSource(queue: .global()) } func start(_ cont: AsyncStream.Continuation) { timer.schedule(deadline: .now(), repeating: .seconds(5)) timer.setEventHandler { cont.yield() } timer.resume() } deinit { self.timer.cancel() } }