-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
add Threads.@once
#51716
Comments
So something like a decrement-only semaphore that other tasks aren't blocked by if they can't decrement, guarding the function call? |
The go implementation actually uses a mutex: |
Yes, you can use a lock and
You'd have to keep the done-ness around of course, which is where a "decrement only" semaphore saves some space, by having a smaller struct. |
I think this was implemented in #55793 I guess we can leave the issue open if someone feels like also adding a macro to wrap those functions and use the feature more easily? |
It might be useful to have a
Threads.@once
macro that guarantees a line of code will only be executed once, either globally or in a given scope, a la C++call_once
or GCDdispatch_once
The text was updated successfully, but these errors were encountered: