Commit a957d12f by Paolo Carlini

condition_variable: Revert inadvertent changes.

2009-12-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/condition_variable: Revert inadvertent changes.
	* testsuite/30_threads/condition_variable/cons/assign_neg.cc: Ditto.
	* testsuite/30_threads/condition_variable/cons/copy_neg.cc: Ditto.
	* testsuite/30_threads/condition_variable/members/1.cc: Ditto.
	* testsuite/30_threads/condition_variable/members/2.cc: Ditto.
	* testsuite/30_threads/condition_variable_any/cons/assign_neg.cc: Ditto.
	* testsuite/30_threads/condition_variable_any/cons/copy_neg.cc: Ditto.

From-SVN: r155343
parent 4ef89725
...@@ -50,9 +50,6 @@ namespace std ...@@ -50,9 +50,6 @@ namespace std
* @{ * @{
*/ */
/// cv_status
enum class cv_status { no_timeout, timeout };
/// condition_variable /// condition_variable
class condition_variable class condition_variable
{ {
...@@ -87,13 +84,13 @@ namespace std ...@@ -87,13 +84,13 @@ namespace std
} }
template<typename _Duration> template<typename _Duration>
cv_status bool
wait_until(unique_lock<mutex>& __lock, wait_until(unique_lock<mutex>& __lock,
const chrono::time_point<__clock_t, _Duration>& __atime) const chrono::time_point<__clock_t, _Duration>& __atime)
{ return __wait_until_impl(__lock, __atime); } { return __wait_until_impl(__lock, __atime); }
template<typename _Clock, typename _Duration> template<typename _Clock, typename _Duration>
cv_status bool
wait_until(unique_lock<mutex>& __lock, wait_until(unique_lock<mutex>& __lock,
const chrono::time_point<_Clock, _Duration>& __atime) const chrono::time_point<_Clock, _Duration>& __atime)
{ {
...@@ -113,14 +110,14 @@ namespace std ...@@ -113,14 +110,14 @@ namespace std
_Predicate __p) _Predicate __p)
{ {
while (!__p()) while (!__p())
if (wait_until(__lock, __atime) == cv_status::timeout) if (!wait_until(__lock, __atime))
return __p(); return __p();
return true; return true;
} }
template<typename _Rep, typename _Period> template<typename _Rep, typename _Period>
cv_status bool
wait_for(unique_lock<mutex>& __lock, wait_for(unique_lock<mutex>& __lock,
const chrono::duration<_Rep, _Period>& __rtime) const chrono::duration<_Rep, _Period>& __rtime)
{ return wait_until(__lock, __clock_t::now() + __rtime); } { return wait_until(__lock, __clock_t::now() + __rtime); }
...@@ -138,7 +135,7 @@ namespace std ...@@ -138,7 +135,7 @@ namespace std
private: private:
template<typename _Clock, typename _Duration> template<typename _Clock, typename _Duration>
cv_status bool
__wait_until_impl(unique_lock<mutex>& __lock, __wait_until_impl(unique_lock<mutex>& __lock,
const chrono::time_point<_Clock, _Duration>& __atime) const chrono::time_point<_Clock, _Duration>& __atime)
{ {
...@@ -157,8 +154,7 @@ namespace std ...@@ -157,8 +154,7 @@ namespace std
__gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(), __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
&__ts); &__ts);
return (_Clock::now() < __atime return _Clock::now() < __atime;
? cv_status::no_timeout : cv_status::timeout);
} }
}; };
...@@ -193,7 +189,7 @@ namespace std ...@@ -193,7 +189,7 @@ namespace std
wait(_Lock& __lock, _Predicate __p); wait(_Lock& __lock, _Predicate __p);
template<typename _Lock, typename _Clock, typename _Duration> template<typename _Lock, typename _Clock, typename _Duration>
cv_status bool
wait_until(_Lock& __lock, wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __atime); const chrono::time_point<_Clock, _Duration>& __atime);
...@@ -205,7 +201,7 @@ namespace std ...@@ -205,7 +201,7 @@ namespace std
_Predicate __p); _Predicate __p);
template<typename _Lock, typename _Rep, typename _Period> template<typename _Lock, typename _Rep, typename _Period>
cv_status bool
wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime); wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime);
template<typename _Lock, typename _Rep, template<typename _Lock, typename _Rep,
......
...@@ -32,4 +32,4 @@ void test01() ...@@ -32,4 +32,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 31 } // { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 70 } // { dg-error "deleted function" "" { target *-*-* } 67 }
...@@ -31,4 +31,4 @@ void test01() ...@@ -31,4 +31,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 30 } // { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "deleted function" "" { target *-*-* } 69 } // { dg-error "deleted function" "" { target *-*-* } 66 }
...@@ -40,8 +40,8 @@ int main() ...@@ -40,8 +40,8 @@ int main()
std::unique_lock<std::mutex> l(m); std::unique_lock<std::mutex> l(m);
auto then = std::chrono::system_clock::now(); auto then = std::chrono::system_clock::now();
std::cv_status result = c1.wait_for(l, ms); bool result = c1.wait_for(l, ms);
VERIFY( result == std::cv_status::timeout ); VERIFY( !result );
VERIFY( (std::chrono::system_clock::now() - then) >= ms ); VERIFY( (std::chrono::system_clock::now() - then) >= ms );
VERIFY( l.owns_lock() ); VERIFY( l.owns_lock() );
} }
......
...@@ -40,8 +40,8 @@ int main() ...@@ -40,8 +40,8 @@ int main()
std::unique_lock<std::mutex> l(m); std::unique_lock<std::mutex> l(m);
auto then = std::chrono::monotonic_clock::now(); auto then = std::chrono::monotonic_clock::now();
std::cv_status result = c1.wait_until(l, then + ms); bool result = c1.wait_until(l, then + ms);
VERIFY( result == std::cv_status::timeout ); VERIFY( !result );
VERIFY( (std::chrono::monotonic_clock::now() - then) >= ms ); VERIFY( (std::chrono::monotonic_clock::now() - then) >= ms );
VERIFY( l.owns_lock() ); VERIFY( l.owns_lock() );
} }
......
...@@ -32,4 +32,4 @@ void test01() ...@@ -32,4 +32,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 31 } // { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 179 } // { dg-error "deleted function" "" { target *-*-* } 175 }
...@@ -31,4 +31,4 @@ void test01() ...@@ -31,4 +31,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 30 } // { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "deleted function" "" { target *-*-* } 178 } // { dg-error "deleted function" "" { target *-*-* } 174 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment