-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
make @sync
lexically scoped and merge @schedule
with @async
#27164
Conversation
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.
My one comment would be that it is easier to deprecate @async
since that is the behaviour this changes. But in general I don't mind much and I think that @async
is the better name.
@sync
lexically scoped and merge @schedule
with @async
@sync
lexically scoped and merge @schedule
with @async
NEWS.md
Outdated
@@ -472,6 +472,11 @@ This section lists changes that do not have deprecation warnings. | |||
* `mv`,`cp`, `touch`, `mkdir`, `mkpath` now return the path that was created/modified | |||
rather than `nothing` ([#27071]). | |||
|
|||
* `@sync` now waits only for *lexically* enclosed (i.e. visible directly in the source |
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.
Probably worth mentioning the deprecation of @schedule
, no?
I'm a little worried by the removal of Some piece of code might call the new Another potential pitfall is a small function that starts out with a I can sympathise with @JeffBezanson's desire to remove unneeded confusion between
Another possibility would be to remove
|
I think that's an important concern. Bringing back schedule but keeping the new behaviour for async seems like a good idea to me. |
With the upcoming threading runtime we will likely be adding more parallel constructs. Unfortunately, we have a few too many similar things (
@async
,@schedule
,@threads
,@spawn
, ...). Confusion between@async
and@schedule
is particularly common and unnecessary; for example some code in the Sockets stdlib uses@async
where it should have used@schedule
.This change improves the situation by removing
@schedule
. The key change to make this possible is to make@sync
lexically scoped. That way, if an@async
appears on its own it just spawns a task and nothing else happens. But if it's lexically surrounded by a@sync
, then that sync waits for all the async stuff inside.It looks to me like basically all uses of
@sync
in the stdlib work with lexical scope. If they don't, it's pretty hard to find that out since dynamic scope is so hard to reason about, giving another reason to make this change :)