diff --git a/README.md b/README.md index 70e3e9041e7..72576a20bee 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem The STL uses boost-math headers to provide P0226R1 Mathematical Special Functions. We recommend using [vcpkg][] to acquire this dependency. -1. Install Visual Studio 2019 16.8 Preview 3 or later. +1. Install Visual Studio 2019 16.8 Preview 4 or later. * We recommend selecting "C++ CMake tools for Windows" in the VS Installer. This will ensure that you're using supported versions of CMake and Ninja. * Otherwise, install [CMake][] 3.17 or later, and [Ninja][] 1.8.2 or later. @@ -158,7 +158,7 @@ acquire this dependency. # How To Build With A Native Tools Command Prompt -1. Install Visual Studio 2019 16.8 Preview 3 or later. +1. Install Visual Studio 2019 16.8 Preview 4 or later. * We recommend selecting "C++ CMake tools for Windows" in the VS Installer. This will ensure that you're using supported versions of CMake and Ninja. * Otherwise, install [CMake][] 3.17 or later, and [Ninja][] 1.8.2 or later. @@ -235,7 +235,7 @@ C:\Users\username\Desktop>dumpbin /IMPORTS .\example.exe | findstr msvcp 1. Follow either [How To Build With A Native Tools Command Prompt][] or [How To Build With The Visual Studio IDE][]. 2. Invoke `git submodule update --init llvm-project` at the root of the STL source tree. -3. Acquire [Python][] 3.8 or newer and have it on the `PATH` (or run it directly using its absolute or relative path). +3. Acquire [Python][] 3.9 or newer and have it on the `PATH` (or run it directly using its absolute or relative path). 4. Have LLVM's `bin` directory on the `PATH` (so `clang-cl.exe` is available). * We recommend selecting "C++ Clang tools for Windows" in the VS Installer. This will automatically add LLVM to the `PATH` of the x86 and x64 Native Tools Command Prompts, and will ensure that you're using a supported version. diff --git a/azure-devops/provision-image.ps1 b/azure-devops/provision-image.ps1 index fb09a22eeea..ea84e185ab1 100644 --- a/azure-devops/provision-image.ps1 +++ b/azure-devops/provision-image.ps1 @@ -97,7 +97,7 @@ $Workloads = @( $ReleaseInPath = 'Preview' $Sku = 'Enterprise' $VisualStudioBootstrapperUrl = 'https://aka.ms/vs/16/pre/vs_enterprise.exe' -$PythonUrl = 'https://www.python.org/ftp/python/3.8.5/python-3.8.5-amd64.exe' +$PythonUrl = 'https://www.python.org/ftp/python/3.9.0/python-3.9.0-amd64.exe' $CudaUrl = ` 'https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_426.00_win10.exe' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49c9a55da32..bc4ce5d12c0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,7 +6,7 @@ variables: tmpDir: 'D:\Temp' -pool: 'StlBuild-2020-09-14' +pool: 'StlBuild-2020-10-13' stages: - stage: Code_Format diff --git a/stl/inc/condition_variable b/stl/inc/condition_variable index 1289183537c..7acd1e47a4e 100644 --- a/stl/inc/condition_variable +++ b/stl/inc/condition_variable @@ -130,7 +130,7 @@ public: template bool wait_for(_Lock& _Lck, const chrono::duration<_Rep, _Period>& _Rel_time, _Predicate _Pred) { // wait for signal with timeout and check predicate - return wait_until(_Lck, chrono::steady_clock::now() + _Rel_time, _STD move(_Pred)); + return wait_until(_Lck, _To_absolute_time(_Rel_time), _STD move(_Pred)); } template @@ -232,7 +232,7 @@ public: template bool wait_for(_Lock& _Lck, stop_token _Stoken, const chrono::duration<_Rep, _Period>& _Rel_time, _Predicate _Pred) { - return wait_until(_Lck, _STD move(_Stoken), chrono::steady_clock::now() + _Rel_time, _STD move(_Pred)); + return wait_until(_Lck, _STD move(_Stoken), _To_absolute_time(_Rel_time), _STD move(_Pred)); } #endif // _HAS_CXX20 diff --git a/stl/inc/mutex b/stl/inc/mutex index 1811ccc021b..501fa02c01f 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -628,7 +628,7 @@ public: template bool wait_for(unique_lock& _Lck, const chrono::duration<_Rep, _Period>& _Rel_time, _Predicate _Pred) { // wait for signal with timeout and check predicate - return _Wait_until1(_Lck, chrono::steady_clock::now() + _Rel_time, _Pred); + return _Wait_until1(_Lck, _To_absolute_time(_Rel_time), _Pred); } template @@ -776,7 +776,7 @@ public: template _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration - return try_lock_until(chrono::steady_clock::now() + _Rel_time); + return try_lock_until(_To_absolute_time(_Rel_time)); } template @@ -875,7 +875,7 @@ public: template _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration - return try_lock_until(chrono::steady_clock::now() + _Rel_time); + return try_lock_until(_To_absolute_time(_Rel_time)); } template diff --git a/stl/inc/shared_mutex b/stl/inc/shared_mutex index 705b1d30f18..06c921d8e76 100644 --- a/stl/inc/shared_mutex +++ b/stl/inc/shared_mutex @@ -110,7 +110,7 @@ public: template _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration - return try_lock_until(chrono::steady_clock::now() + _Rel_time); + return try_lock_until(_To_absolute_time(_Rel_time)); } template @@ -168,7 +168,7 @@ public: template _NODISCARD bool try_lock_shared_for( const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock non-exclusive for relative time - return try_lock_shared_until(_Rel_time + chrono::steady_clock::now()); + return try_lock_shared_until(_To_absolute_time(_Rel_time)); } template diff --git a/stl/inc/thread b/stl/inc/thread index 20d6ee84272..583cdcf6631 100644 --- a/stl/inc/thread +++ b/stl/inc/thread @@ -156,6 +156,22 @@ private: _Thrd_t _Thr; }; +template +_NODISCARD auto _To_absolute_time(const chrono::duration<_Rep, _Period>& _Rel_time) noexcept { + constexpr auto _Zero = chrono::duration<_Rep, _Period>::zero(); + const auto _Now = chrono::steady_clock::now(); + decltype(_Now + _Rel_time) _Abs_time = _Now; // return common type + if (_Rel_time > _Zero) { + constexpr auto _Forever = (chrono::steady_clock::time_point::max)(); + if (_Abs_time < _Forever - _Rel_time) { + _Abs_time += _Rel_time; + } else { + _Abs_time = _Forever; + } + } + return _Abs_time; +} + namespace this_thread { _NODISCARD thread::id get_id() noexcept; @@ -183,7 +199,7 @@ namespace this_thread { template void sleep_for(const chrono::duration<_Rep, _Period>& _Rel_time) { - sleep_until(chrono::steady_clock::now() + _Rel_time); + sleep_until(_To_absolute_time(_Rel_time)); } } // namespace this_thread diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b8059d68cd6..1103c9dd3bc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,7 +18,7 @@ add_subdirectory(tr1) # chance to add to the config map and test directory global properties. add_subdirectory(utils/stl-lit) -find_package(Python "3.8" REQUIRED COMPONENTS Interpreter) +find_package(Python "3.9" REQUIRED COMPONENTS Interpreter) if(NOT DEFINED LIT_FLAGS) list(APPEND LIT_FLAGS "-o" "${CMAKE_CURRENT_BINARY_DIR}/test_results.json") diff --git a/tests/std/tests/P0660R10_jthread_and_cv_any/test.cpp b/tests/std/tests/P0660R10_jthread_and_cv_any/test.cpp index 1495227aacd..dfe79d60dde 100644 --- a/tests/std/tests/P0660R10_jthread_and_cv_any/test.cpp +++ b/tests/std/tests/P0660R10_jthread_and_cv_any/test.cpp @@ -180,7 +180,7 @@ int main() { jthread worker([&](stop_token token) { unique_lock lck{m}; assert(cv.wait(lck, move(token), [] { return true; }) == true); - assert(cv.wait(lck, move(token), [&] { return b; }) == true); + assert(cv.wait(lck, move(token), [&] { return b; }) == true); // Intentionally uses moved-from token }); { @@ -198,7 +198,8 @@ int main() { jthread worker([&](stop_token token) { unique_lock lck{m}; assert(cv.wait_until(lck, move(token), infinity, [] { return true; }) == true); - assert(cv.wait_until(lck, move(token), infinity, [&] { return b; }) == true); + assert(cv.wait_until(lck, move(token), infinity, [&] { return b; }) + == true); // Intentionally uses moved-from token }); { @@ -216,7 +217,8 @@ int main() { jthread worker([&](stop_token token) { unique_lock lck{m}; assert(cv.wait_for(lck, move(token), forever, [] { return true; }) == true); - assert(cv.wait_for(lck, move(token), forever, [&] { return b; }) == true); + assert(cv.wait_for(lck, move(token), forever, [&] { return b; }) + == true); // Intentionally uses moved-from token }); {