Cleanups: Simplify thread and condition_variable, identify unused dllexports#3532
Merged
StephanTLavavej merged 4 commits intomicrosoft:mainfrom Mar 7, 2023
Merged
Conversation
_Thrd_detach() returns either _Thrd_success or _Thrd_error. _Throw_C_error() translates that to _Throw_Cpp_error(_INVALID_ARGUMENT).
_Cnd_timedwait() returns only _Thrd_success or _Thrd_timedout, allowing us to simplify later code. After this, _Throw_C_error() is unused. (No redist impact, still exported.) We don't need the `extern "C++"` from the declaration in stl/inc/xthreads.h - that's for Standard Library Modules, but stl/src/thread0.cpp is always built classically.
Member
Author
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains fairly simple logic transformations - they aren't exactly trivial (as one must consult other code to verify their correctness), but they're far from complicated. There's no behavioral impact, no changes to dllexports, and no interaction with the "unlocked" state of the redist.
_Xtime_diff_to_millis()is unused. We can drop its declaration ininc/xtimec.hand mark its definition insrc/xtime.cppas preserved for bincompat. When doing this, all we need to do is verify that the declaration and the definition contain all of the same annotations (in particular,_CRTIMP2_PUREcontrols dllexporting).thread::detach(), part 1.inc/xthreads.hprovided aninlinehelper_Check_C_return(). Originally, it may have been used widely, but now there's only one usage. We can manually fuse it intothread::detach().thread::detach(), part 2._Thrd_detach()returns either_Thrd_successor_Thrd_error:STL/stl/src/cthread.cpp
Lines 71 to 73 in 16bb556
_Throw_C_error()translates that to_Throw_Cpp_error(_INVALID_ARGUMENT):STL/stl/src/thread0.cpp
Lines 47 to 48 in 16bb556
thread::join()above, and more clearly shows what exception will be thrown._Cnd_timedwait()returns only_Thrd_successor_Thrd_timedout. There's only onereturn, and only two values thatrescan take:STL/stl/src/cond.cpp
Lines 63 to 83 in 16bb556
_Cnd_timedwait(), as we don't need to worry about unexpected return values._Throw_C_error()is unused, so we can drop its declaration and mark its definition as preserved for bincompat.extern "C++"from the declaration ininc/xthreads.h- that's for Standard Library Modules, butsrc/thread0.cppis always built classically.