Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed WorkflowConcurrency Worker task priority to high #306

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion WorkflowConcurrency/Sources/Worker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
associatedtype Output

/// Execute the work represented by this worker asynchronously and return the result.
/// This function will be run in a Task set to high priority.
func run() async -> Output
/// Returns `true` if the other worker should be considered equivalent to `self`. Equivalence should take into
/// account whatever data is meaningful to the task. For example, a worker that loads a user account from a server
Expand Down Expand Up @@ -63,7 +64,7 @@
let sink = context.makeOutputSink()
context.runSideEffect(key: state) { lifetime in
let send: @MainActor(Output) -> Void = sink.send
let task = Task {
let task = Task(priority: .high) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a note in one of the doc comments about this behavior

logger.logStarted()
let output = await worker.run()
if Task.isCancelled {
Expand All @@ -73,7 +74,7 @@
}
logger.logOutput()
logger.logFinished(status: "Finished")
await send(output)

Check warning on line 77 in WorkflowConcurrency/Sources/Worker.swift

View workflow job for this annotation

GitHub Actions / development-tests (UnitTests)

passing argument of non-sendable type 'WorkerType.Output' into main actor-isolated context may introduce data races
}
lifetime.onEnded {
task.cancel()
Expand Down
Loading