Rename condition_variable_any wait* methods to match current draft standard
2020-01-07 Thomas Rodgers <trodgers@redhat.com> * include/std/condition_variable (condition_variable_any::wait_on): Rename to match current draft standard. (condition_variable_any::wait_on_until): Likewise. (condition_variable_any::wait_on_for): Likewise. * testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc: Adjust tests to account for renamed methods. From-SVN: r279988
This commit is contained in:
parent
42d73fa9d5
commit
9e3c1eb773
3 changed files with 36 additions and 26 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2020-01-07 Thomas Rodgers <trodgers@redhat.com>
|
||||||
|
|
||||||
|
* include/std/condition_variable
|
||||||
|
(condition_variable_any::wait_on): Rename to match current draft
|
||||||
|
standard.
|
||||||
|
(condition_variable_any::wait_on_until): Likewise.
|
||||||
|
(condition_variable_any::wait_on_for): Likewise.
|
||||||
|
* testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc:
|
||||||
|
Adjust tests to account for renamed methods.
|
||||||
|
|
||||||
2020-01-07 François Dumont <fdumont@gcc.gnu.org>
|
2020-01-07 François Dumont <fdumont@gcc.gnu.org>
|
||||||
|
|
||||||
PR libstdc++/92124
|
PR libstdc++/92124
|
||||||
|
|
|
@ -369,9 +369,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
#ifdef __cpp_lib_jthread
|
#ifdef __cpp_lib_jthread
|
||||||
template <class _Lock, class _Predicate>
|
template <class _Lock, class _Predicate>
|
||||||
bool wait_on(_Lock& __lock,
|
bool wait(_Lock& __lock,
|
||||||
stop_token __stoken,
|
stop_token __stoken,
|
||||||
_Predicate __p)
|
_Predicate __p)
|
||||||
{
|
{
|
||||||
if (__stoken.stop_requested())
|
if (__stoken.stop_requested())
|
||||||
{
|
{
|
||||||
|
@ -397,10 +397,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Lock, class _Clock, class _Duration, class _Predicate>
|
template <class _Lock, class _Clock, class _Duration, class _Predicate>
|
||||||
bool wait_on_until(_Lock& __lock,
|
bool wait_until(_Lock& __lock,
|
||||||
stop_token __stoken,
|
stop_token __stoken,
|
||||||
const chrono::time_point<_Clock, _Duration>& __abs_time,
|
const chrono::time_point<_Clock, _Duration>& __abs_time,
|
||||||
_Predicate __p)
|
_Predicate __p)
|
||||||
{
|
{
|
||||||
if (__stoken.stop_requested())
|
if (__stoken.stop_requested())
|
||||||
{
|
{
|
||||||
|
@ -432,16 +432,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Lock, class _Rep, class _Period, class _Predicate>
|
template <class _Lock, class _Rep, class _Period, class _Predicate>
|
||||||
bool wait_on_for(_Lock& __lock,
|
bool wait_for(_Lock& __lock,
|
||||||
stop_token __stoken,
|
stop_token __stoken,
|
||||||
const chrono::duration<_Rep, _Period>& __rel_time,
|
const chrono::duration<_Rep, _Period>& __rel_time,
|
||||||
_Predicate __p)
|
_Predicate __p)
|
||||||
{
|
{
|
||||||
auto __abst = std::chrono::steady_clock::now() + __rel_time;
|
auto __abst = std::chrono::steady_clock::now() + __rel_time;
|
||||||
return wait_on_until(__lock,
|
return wait_until(__lock,
|
||||||
std::move(__stoken),
|
std::move(__stoken),
|
||||||
__abst,
|
__abst,
|
||||||
std::move(__p));
|
std::move(__p));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
using namespace::std::literals;
|
using namespace::std::literals;
|
||||||
|
|
||||||
void test_wait_on_stop()
|
void test_wait_stop()
|
||||||
{
|
{
|
||||||
bool ready = false;
|
bool ready = false;
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
|
@ -40,7 +40,7 @@ void test_wait_on_stop()
|
||||||
std::thread t([&ready, &mtx, &cv, tok]
|
std::thread t([&ready, &mtx, &cv, tok]
|
||||||
{
|
{
|
||||||
std::unique_lock lck(mtx);
|
std::unique_lock lck(mtx);
|
||||||
auto res = cv.wait_on(lck, tok, [&ready] { return ready; });
|
auto res = cv.wait(lck, tok, [&ready] { return ready; });
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
VERIFY(tok.stop_requested());
|
VERIFY(tok.stop_requested());
|
||||||
|
@ -54,7 +54,7 @@ void test_wait_on_stop()
|
||||||
VERIFY(src.stop_requested());
|
VERIFY(src.stop_requested());
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_wait_on_until(bool ck = true)
|
void test_wait_until(bool ck = true)
|
||||||
{
|
{
|
||||||
bool ready = false;
|
bool ready = false;
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
|
@ -67,7 +67,7 @@ void test_wait_on_until(bool ck = true)
|
||||||
std::thread t([ck, &ready, &mtx, &cv, abst, tok]
|
std::thread t([ck, &ready, &mtx, &cv, abst, tok]
|
||||||
{
|
{
|
||||||
std::unique_lock lck(mtx);
|
std::unique_lock lck(mtx);
|
||||||
auto res = cv.wait_on_until(lck, tok, abst, [&ready] { return ready; });
|
auto res = cv.wait_until(lck, tok, abst, [&ready] { return ready; });
|
||||||
if (!res && ck)
|
if (!res && ck)
|
||||||
{
|
{
|
||||||
VERIFY(tok.stop_requested());
|
VERIFY(tok.stop_requested());
|
||||||
|
@ -90,7 +90,7 @@ void test_wait_on_until(bool ck = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_wait_on_for(bool ck = true)
|
void test_wait_for(bool ck = true)
|
||||||
{
|
{
|
||||||
bool ready = false;
|
bool ready = false;
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
|
@ -102,7 +102,7 @@ void test_wait_on_for(bool ck = true)
|
||||||
std::thread t([ck, &ready, &mtx, &cv, tok]
|
std::thread t([ck, &ready, &mtx, &cv, tok]
|
||||||
{
|
{
|
||||||
std::unique_lock lck(mtx);
|
std::unique_lock lck(mtx);
|
||||||
auto res = cv.wait_on_for(lck, tok, 1.0s, [&ready] { return ready; });
|
auto res = cv.wait_for(lck, tok, 1.0s, [&ready] { return ready; });
|
||||||
if (!res && ck)
|
if (!res && ck)
|
||||||
{
|
{
|
||||||
VERIFY(tok.stop_requested());
|
VERIFY(tok.stop_requested());
|
||||||
|
@ -127,10 +127,10 @@ void test_wait_on_for(bool ck = true)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test_wait_on_stop();
|
test_wait_stop();
|
||||||
test_wait_on_until(false);
|
test_wait_until(false);
|
||||||
test_wait_on_until();
|
test_wait_until();
|
||||||
test_wait_on_for();
|
test_wait_for();
|
||||||
test_wait_on_for(false);
|
test_wait_for(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue