-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] Correct memory effect attributes of task_create #82179
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
Merged
ktoso
merged 1 commit into
swiftlang:main
from
ktoso:wip-fix-incorrect-memory-effects-on-task-create
Jun 12, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -392,28 +392,6 @@ print("callActorFromStartSynchronousTask() - actor in custom executor with its o | |
let actorQueue = DispatchQueue(label: "recipient-actor-queue") | ||
callActorFromStartSynchronousTask(recipient: .recipientOnQueue(RecipientOnQueue(queue: actorQueue))) | ||
|
||
|
||
// 50: callActorFromStartSynchronousTask() | ||
// 51: before immediate [thread:0x00007000054f5000] @ :366 | ||
// 52: inside immediate [thread:0x00007000054f5000] @ :372 | ||
// 53: inside immediate, call rec.sync() [thread:0x00007000054f5000] @ :380 | ||
// 54: Recipient/sync(syncTaskThreadID:) Current actor thread id = 0x000070000567e000 @ :336 | ||
// 55: inside immediate, call rec.sync() done [thread:0x000070000567e000] @ :385 | ||
// 56: Inner thread id = 0x00007000054f5000 | ||
// 57: Current thread id = 0x000070000567e000 | ||
// 60: after immediate [thread:0x00007000054f5000] @ :418 | ||
// 61: - async work on queue | ||
// 62: - async work on queue | ||
// 63: - async work on queue | ||
// 64: - async work on queue | ||
// 65: - async work on queue | ||
// 67: - async work on queue | ||
// 68: - async work on queue | ||
// 69: - async work on queue | ||
// 71: Inner thread id = 0x00007000054f5000 | ||
// 72: Current thread id = 0x000070000567e000 | ||
// 73: inside immediate, done [thread:0x000070000567e000] @ :414 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to keep this in tree, was debug information |
||
|
||
// CHECK-LABEL: callActorFromStartSynchronousTask() - actor in custom executor with its own queue | ||
// No interleaving allowed between "before" and "inside": | ||
// CHECK: before immediate [thread:[[CALLING_THREAD4:.*]]] | ||
|
@@ -452,3 +430,33 @@ actor RecipientOnQueue: RecipientProtocol { | |
try? await Task.sleep(for: .milliseconds(100)) | ||
} | ||
} | ||
|
||
print("\n\n==== ------------------------------------------------------------------") | ||
print("call_startSynchronously_insideActor()") | ||
|
||
actor A { | ||
func f() { | ||
Task.startSynchronously(name: "hello") { print("Task.startSynchronously (\(Task.name!))") } | ||
Task.startSynchronously() { print("Task.startSynchronously") } | ||
} | ||
|
||
func f2() { | ||
Task.immediate(name: "hello") { print("Task.immediate (\(Task.name!))") } | ||
Task.immediate() { print("Task.immediate") } | ||
|
||
Task.immediate(name: "hello") { @MainActor in print("Task.immediate { @MainActor } (\(Task.name!))") } | ||
Task.immediate() { @MainActor in print("Task.immediate { @MainActor }") } | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. testing both with names and not, to be "extra" sure these don't regress somehow |
||
|
||
func call_startSynchronously_insideActor() async { | ||
await A().f() | ||
await A().f2() | ||
} | ||
|
||
await call_startSynchronously_insideActor() | ||
|
||
// CHECK-LABEL: call_startSynchronously_insideActor() | ||
// Those two definitely in this order, however the startSynchronously is not determinate | ||
// CHECK: Task.immediate | ||
// CHECK: Task.immediate { @MainActor } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we actually did adopt
sending
here already, so we can remove the comment about needing to do so when a bug was fixed