TimeSyncer: Amend some bits (#404)

This commit is contained in:
Danny Canter
2025-11-12 09:39:26 -08:00
committed by GitHub
parent a31abd73a4
commit bbe9ebd8fa
+8 -2
View File
@@ -29,7 +29,10 @@ actor TimeSyncer {
}
func start(context: Vminitd, interval: Duration = .seconds(30)) {
precondition(task == nil, "time syncer is already running")
guard self.task == nil else {
return
}
self.context = context
self.task = Task {
while true {
@@ -70,10 +73,13 @@ actor TimeSyncer {
func close() async throws {
guard let task else {
preconditionFailure("time syncer was already closed")
// Already closed, nop.
return
}
task.cancel()
await task.value
try await self.context?.close()
self.task = nil
self.context = nil