-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from d-exclaimation/chore/test-cleanup-1
Task starvation solutions + better test websocket client
- Loading branch information
Showing
5 changed files
with
148 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Task+Starvation.swift | ||
// pioneer | ||
// | ||
// Created by d-exclaimation on 22:38. | ||
// | ||
|
||
public extension Task where Success == Never, Failure == Never { | ||
/// Postpone the current task and allows other tasks to execute. | ||
/// | ||
/// A task can voluntarily suspend itself in the middle of a long-running operation that doesn’t contain any suspension points, to let other tasks run for a while before execution returns to this task. | ||
/// | ||
/// This is a sister method to ``Task/yield()``, which is a suspension point that allows other tasks to run that forces the suspension of the current task and ignores the current task’s priority. | ||
static func postpone() async throws { | ||
try await Task.sleep(nanoseconds: 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.