Files
bot/apps/macos/Sources/Bot/SimpleTaskSupport.swift
zooqueen fd1d312208 feat: merge upstream improvements via rebrand bridge
Squash merge of 1,462 upstream commits with openclaw→hanzo-bot
naming transforms applied. Conflicts resolved favoring our main
branch to preserve existing customizations.

Key upstream additions:
- iOS Security Stack (concurrency locks, runtime guards, TTS fallback)
- Discord CDN hostname allowlisting for SSRF protection
- Discord mention handling improvements
- Various bug fixes and stability improvements
2026-03-03 09:38:30 -08:00

32 lines
837 B
Swift

import Foundation
@MainActor
enum SimpleTaskSupport {
static func start(task: inout Task<Void, Never>?, operation: @escaping @Sendable () async -> Void) {
guard task == nil else { return }
task = Task {
await operation()
}
}
static func stop(task: inout Task<Void, Never>?) {
task?.cancel()
task = nil
}
static func startDetachedLoop(
task: inout Task<Void, Never>?,
interval: TimeInterval,
operation: @escaping @Sendable () async -> Void)
{
guard task == nil else { return }
task = Task.detached {
await operation()
while !Task.isCancelled {
try? await Task.sleep(nanoseconds: UInt64(interval * 1_000_000_000))
await operation()
}
}
}
}