test context

This commit is contained in:
anlicheng 2025-08-20 19:10:17 +08:00
parent 075010703a
commit f410433aac

View File

@ -108,6 +108,10 @@ public class SDLContext: @unchecked Sendable {
self.rootTask = Task {
try await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
defer {
self.logger.log("[SDLContext] UDPHole exit", level: .debug)
}
while !Task.isCancelled {
do {
try await self.startUDPHole()
@ -119,6 +123,10 @@ public class SDLContext: @unchecked Sendable {
}
group.addTask {
defer {
self.logger.log("[SDLContext] SuperClient exit", level: .debug)
}
while !Task.isCancelled {
do {
try await self.startSuperClient()
@ -135,6 +143,10 @@ public class SDLContext: @unchecked Sendable {
}
group.addTask {
defer {
self.logger.log("[SDLContext] noticeClient exit", level: .debug)
}
while !Task.isCancelled {
do {
try await self.startNoticeClient()
@ -149,6 +161,11 @@ public class SDLContext: @unchecked Sendable {
}
}
Task {
try await Task.sleep(for: .seconds(20))
self.rootTask?.cancel()
}
try await self.rootTask?.value
}