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

[EXPERIMENTAL] Add Actor.runSynchronously() to synchronously wait for a closure to execute on an actor #77749

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DougGregor
Copy link
Member

The operation is executed at the given priority, and is in the same way as all other work on the actor. If the calling thread manages to take the actor lock, it will execute jobs up until this operation is completed, then return. Otherwise, it will block waiting for a different thread to execute this operation.

This operation is only available for default actors (ones that do not have custom executors), and will trap if provided with an actor that has a custom executor. Note that the blocking nature of this operation makes it prone to deadlock, so it should be used sparingly.

…xecute on an actor

The operation is executed at the given priority, and is in the same way as
all other work on the actor. If the calling thread manages to take the
actor lock, it will execute jobs up until this operation is completed,
then return. Otherwise, it will block waiting for a different thread to
execute this operation.

This operation is only available for default actors (ones that do not have
custom executors), and will trap if provided with an actor that has a
custom executor. Note that the blocking nature of this operation makes it
prone to deadlock, so it should be used sparingly.
@DougGregor DougGregor marked this pull request as draft November 20, 2024 21:36
@DougGregor
Copy link
Member Author

@swift-ci please test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Yeah that makes sense to enqueue a SynchronousWaitJob... Waiting impl is the simplest thing I had in mind, very curious if it'd work out well enough vs run loop involving tricks. If we were to do it for real it probably would be better without adding new param to enqueue() but checking job kind?

API discussion leaving out for later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants