-
-
Notifications
You must be signed in to change notification settings - Fork 739
let initOnce take a shared Mutex #5661
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
Conversation
Thanks for your pull request, @aG0aep6G! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
std/concurrency.d
Outdated
@@ -2502,14 +2502,20 @@ auto ref initOnce(alias var)(lazy typeof(var) init, Mutex mutex) | |||
return var; | |||
} | |||
|
|||
deprecated("use the overload that takes a `shared(Mutex)`") | |||
auto ref initOnce(alias var)(lazy typeof(var) init, Mutex mutex) |
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.
Not sure about this. Should we deprecate code that's been using __gshared
mutexes without issue?
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.
Let's not (yet). Mutex
didn't work with shared
at all for the longest time, and I'm not even sure how well it fits within the (theoretical) shared
model.
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.
Let's not (yet).
Ok, how about changing the deprecation to a comment in the docs indicating that the this non-shared
overload may be deprecated in the future, so to discourage the use in new code.
Mutex didn't work with shared at all for the longest time
Yeah, it was a shame. Now that dlang/druntime#1728 is merged we should be good, no?
I'm not even sure how well it fits within the (theoretical) shared model.
@klickverbot Can you take a look at http://dlang.org/phobos-prerelease/core_sync_mutex and the source and check if there's anything that can be improved w.r.t. the correct use of the shared
type qualifier?
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.
Ok, how about changing the deprecation to a comment in the docs indicating that the this non-shared overload may be deprecated in the future
Yep, anything like that would be fine – the point is just to decouple allowing shared
from forcing it, as the former is entirely uncontroversial. As for the latter, I don't currently see any issues with Mutex
and shared
as it stands (unless we end up moving towards more ownership-based semantics), but as long as we don't have shared
nailed down, it seems unwise to break too much code that is just as valid without it.
Actually, thinking about it: Even if shared
actually implied non-thread-local right now, it seems like calling initOnce
with a thread-local mutex wouldn't be invalid. Requiring shared
would just serve to catch bugs where a thread-local mutex is passed by accident (e.g. by leaving shared
off a static variable).
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.
I've un-deprecated the unshared overload. Not adding a comment about future deprecation, because it's not clear (to me) what's going to happen.
924852a
to
82fe75f
Compare
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.
Looks a lot nicer :)
Thanks for pushing this!
As initiated by @ZombineDev (#4551 (comment)).
Depends on #4551 (included here) and dlang/druntime#1605.