-
Notifications
You must be signed in to change notification settings - Fork 1.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 ~mutex
trivial
#4390
Make ~mutex
trivial
#4390
Conversation
By simply removing `~_Mutex_base`. This destructor has been only a debug check since microsoftGH-3770. Losing the debug check is a small price to pay to elide the destructor call, doubly so for static storage duration mutexes that now won't need dynamic initializers to register with `at_exit`. `_Mtx_destroy` and `_Mtx_destroy_in_situ` are only called by APIs preserved for binary compatibility, so mark them as also "preserved for binary compatibility".
@@ -45,10 +45,6 @@ public: | |||
} | |||
#endif // ^^^ !defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) ^^^ | |||
|
|||
~_Mutex_base() noexcept { | |||
_Mtx_destroy_in_situ(_Mymtx()); |
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 could be convinced to retain this debug check for ~recursive_mutex
, which feels less performance-sensitive to me. Thoughts, comments?
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'm fine with dropping it.
@@ -45,10 +45,6 @@ public: | |||
} | |||
#endif // ^^^ !defined(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) ^^^ | |||
|
|||
~_Mutex_base() noexcept { | |||
_Mtx_destroy_in_situ(_Mymtx()); |
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'm fine with dropping it.
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for this trivial PR with nontrivial impact! 😹 🚀 🎉 |
By simply removing
~_Mutex_base
. This destructor has been only a debug check since GH-3770. Losing the debug check is a small price to pay to elide the destructor call, doubly so for static storage duration mutexes that now won't need dynamic initializers to register withat_exit
._Mtx_destroy
and_Mtx_destroy_in_situ
are only called by APIs preserved for binary compatibility, so mark them as also "preserved for binary compatibility".