-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
Sometimes you just wanna reset the timeout timer if forward progress is made - I think this could be a great feature! Probably just some sort of closure passed to to the caller's async body, something like:
public func withThrowingResettableTimeout<T>(
isolation: isolated (any Actor)? = #isolation,
seconds: TimeInterval,
body: (_ resetTimeout: () -> Void) async throws -> sending T
)
my particular use case would be something like (using FlyingSocks)
try await withThrowingResettableTimeout(seconds: 90) { resetTimeout in
for try await message in socket.messages {
resetTimeout()
let response = try await handleSocketMessage(message.payload)
try await socket.write(response)
}
}
try? socket.close()
Metadata
Metadata
Assignees
Labels
No labels