Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stl/inc/__msvc_threads_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define __MSVC_THREADS_CORE_HPP
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <type_traits>
#include <cstddef>

#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
Expand Down Expand Up @@ -43,7 +43,7 @@ struct _Mtx_internal_imp_t {
int _Type{};
union {
_Stl_critical_section _Critical_section{};
_STD _Aligned_storage_t<_Critical_section_size, alignof(void*)> _Cs_storage;
alignas(void*) unsigned char _Cs_storage[_Critical_section_size];
};
long _Thread_id{};
int _Count{};
Expand All @@ -68,7 +68,7 @@ struct _Cnd_internal_imp_t {

union {
_Stl_condition_variable _Stl_cv{};
_STD _Aligned_storage_t<_Cnd_internal_imp_size, alignof(void*)> _Cv_storage;
alignas(void*) unsigned char _Cv_storage[_Cnd_internal_imp_size];
};
};
#pragma warning(pop)
Expand Down
22 changes: 11 additions & 11 deletions tests/std/tests/P0660R10_jthread_and_cv_any/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,30 @@ int main() {
assert(jthread::hardware_concurrency() == thread::hardware_concurrency());

{ // first wait_until overload; without the cancellation this would deadlock
jthread worker([](stop_token token) {
mutex m;
condition_variable_any cv;
mutex m;
condition_variable_any cv;
jthread worker([&](stop_token token) {
unique_lock lck{m};
assert(cv.wait(lck, move(token), [] { return false; }) == false);
});
}

static constexpr auto forever = chrono::steady_clock::duration::max();
static constexpr auto infinity = chrono::steady_clock::time_point::max();
constexpr auto forever = chrono::steady_clock::duration::max();
constexpr auto infinity = chrono::steady_clock::time_point::max();

{ // ditto without the cancellation this would deadlock
jthread worker([](stop_token token) {
mutex m;
condition_variable_any cv;
mutex m;
condition_variable_any cv;
jthread worker([&](stop_token token) {
unique_lock lck{m};
assert(cv.wait_until(lck, move(token), infinity, [] { return false; }) == false);
});
}

{ // ditto without the cancellation this would deadlock
jthread worker([](stop_token token) {
mutex m;
condition_variable_any cv;
mutex m;
condition_variable_any cv;
jthread worker([&](stop_token token) {
unique_lock lck{m};
assert(cv.wait_for(lck, move(token), forever, [] { return false; }) == false);
});
Expand Down