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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion azure-devops/provision-image.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
variables:
tmpDir: 'D:\Temp'

pool: 'StlBuild-2020-09-14'
pool: 'StlBuild-2020-10-13'

stages:
- stage: Code_Format
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/condition_variable
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public:
template <class _Lock, class _Rep, class _Period, class _Predicate>
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 <class _Lock>
Expand Down Expand Up @@ -232,7 +232,7 @@ public:

template <class _Lock, class _Rep, class _Period, class _Predicate>
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

Expand Down
6 changes: 3 additions & 3 deletions stl/inc/mutex
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public:
template <class _Rep, class _Period, class _Predicate>
bool wait_for(unique_lock<mutex>& _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 <class _Clock, class _Duration>
Expand Down Expand Up @@ -776,7 +776,7 @@ public:

template <class _Rep, class _Period>
_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 <class _Time>
Expand Down Expand Up @@ -875,7 +875,7 @@ public:

template <class _Rep, class _Period>
_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 <class _Time>
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/shared_mutex
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public:

template <class _Rep, class _Period>
_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 <class _Clock, class _Duration>
Expand Down Expand Up @@ -168,7 +168,7 @@ public:
template <class _Rep, class _Period>
_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 <class _Time>
Expand Down
18 changes: 17 additions & 1 deletion stl/inc/thread
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ private:
_Thrd_t _Thr;
};

template <class _Rep, class _Period>
_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;

Expand Down Expand Up @@ -183,7 +199,7 @@ namespace this_thread {

template <class _Rep, class _Period>
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

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 5 additions & 3 deletions tests/std/tests/P0660R10_jthread_and_cv_any/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

{
Expand All @@ -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
});

{
Expand All @@ -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
});

{
Expand Down