Commit d3098c94 by Chris Fairles Committed by Paolo Carlini

condition_variable: Update to N2691 WD.

2008-07-23  Chris Fairles <chris.fairles@gmail.com>

        * include/std/condition_variable: Update to N2691 WD.
        * include/std/mutex: Likewise.
        * testsuite/30_threads/mutex/cons/assign_neg.cc: Adjust line numbers.
        * testsuite/30_threads/mutex/cons/copy_neg.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Likewise.
        * testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Likewise.

From-SVN: r138096
parent 3e293154
2008-07-23 Chris Fairles <chris.fairles@gmail.com> 2008-07-23 Chris Fairles <chris.fairles@gmail.com>
* include/std/condition_variable: Update to N2691 WD.
* include/std/mutex: Likewise.
* testsuite/30_threads/mutex/cons/assign_neg.cc: Adjust line numbers.
* testsuite/30_threads/mutex/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Likewise.
* testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Likewise.
2008-07-23 Chris Fairles <chris.fairles@gmail.com>
* acinclude.m4 ([GLIBCXX_CHECK_CLOCK_GETTIME]): Define GLIBCXX_LIBS. * acinclude.m4 ([GLIBCXX_CHECK_CLOCK_GETTIME]): Define GLIBCXX_LIBS.
Holds the lib that defines clock_gettime (-lrt or -lposix4). Holds the lib that defines clock_gettime (-lrt or -lposix4).
* src/Makefile.am: Use it. * src/Makefile.am: Use it.
...@@ -78,10 +87,10 @@ ...@@ -78,10 +87,10 @@
Update error lineno. Update error lineno.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Update error lineno. Update error lineno.
* testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc: * testsuite/23_containers/vector/requirements/dr438/
Update error lineno. constructor_1_neg.cc: Update error lineno.
* testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc: * testsuite/23_containers/vector/requirements/dr438/
Update error lineno. constructor_2_neg.cc: Update error lineno.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: * testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Update error lineno. Update error lineno.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
......
...@@ -44,8 +44,14 @@ ...@@ -44,8 +44,14 @@
namespace std namespace std
{ {
// XXX namespace chrono
class system_time; {
template<typename _Rep, typename _Period>
struct duration;
template<typename _Clock, typename _Duration>
struct time_point;
}
/// condition_variable /// condition_variable
class condition_variable class condition_variable
...@@ -78,22 +84,27 @@ namespace std ...@@ -78,22 +84,27 @@ namespace std
wait(__lock); wait(__lock);
} }
template<typename _Duration> template<typename _Clock, typename _Duration>
bool bool
timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime); wait_until(unique_lock<mutex>& __lock,
const chrono::time_point<_Clock, _Duration>& __atime);
template<typename _Clock, typename _Duration, typename _Predicate>
bool bool
timed_wait(unique_lock<mutex>& __lock, const system_time& __atime); wait_until(unique_lock<mutex>& __lock,
const chrono::time_point<_Clock, _Duration>& __atime,
_Predicate __p);
template<typename _Predicate> template<typename _Rep, typename _Period>
bool bool
timed_wait(unique_lock<mutex>& __lock, const system_time& __atime, wait_for(unique_lock<mutex>& __lock,
_Predicate pred); const chrono::duration<_Rep, _Period>& __rtime);
template<typename _Duration, typename _Predicate> template<typename _Rep, typename _Period, typename _Predicate>
bool bool
timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime, wait_for(unique_lock<mutex>& __lock,
_Predicate pred); const chrono::duration<_Rep, _Period>& __rtime,
_Predicate __p);
native_handle_type native_handle_type
native_handle() { return _M_cond; } native_handle() { return _M_cond; }
...@@ -132,21 +143,27 @@ namespace std ...@@ -132,21 +143,27 @@ namespace std
void void
wait(_Lock& __lock, _Predicate __p); wait(_Lock& __lock, _Predicate __p);
template<typename _Lock> template<typename _Lock, typename _Clock, typename _Duration>
bool bool
timed_wait(_Lock& __lock, const system_time& __atime); wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __atime);
template<typename _Lock, typename _Duration> template<typename _Lock, typename _Clock,
typename _Duration, typename _Predicate>
bool bool
timed_wait(_Lock& __lock, const _Duration& __rtime); wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __atime,
_Predicate __p);
template<typename _Lock, typename _Predicate> template<typename _Lock, typename _Rep, typename _Period>
bool bool
timed_wait(_Lock& __lock, const system_time& __atime, _Predicate __p); wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime);
template<typename _Lock, typename _Duration, typename _Predicate> template<typename _Lock, typename _Rep,
typename _Period, typename _Predicate>
bool bool
timed_wait(_Lock& __lock, const _Duration& __rtime, _Predicate __p); wait_for(_Lock& __lock,
const chrono::duration<_Rep, _Period>& __rtime, _Predicate __p);
native_handle_type native_handle_type
native_handle() { return _M_cond; } native_handle() { return _M_cond; }
......
...@@ -48,8 +48,14 @@ ...@@ -48,8 +48,14 @@
namespace std namespace std
{ {
// XXX namespace chrono
class system_time; {
template<typename _Rep, typename _Period>
struct duration;
template<typename _Clock, typename _Duration>
struct time_point;
}
/// mutex /// mutex
class mutex class mutex
...@@ -102,7 +108,6 @@ namespace std ...@@ -102,7 +108,6 @@ namespace std
mutex& operator=(const mutex&); mutex& operator=(const mutex&);
}; };
/// recursive_mutex /// recursive_mutex
class recursive_mutex class recursive_mutex
{ {
...@@ -145,7 +150,8 @@ namespace std ...@@ -145,7 +150,8 @@ namespace std
} }
native_handle_type native_handle_type
native_handle() { return _M_mutex; } native_handle()
{ return _M_mutex; }
private: private:
native_handle_type _M_mutex; native_handle_type _M_mutex;
...@@ -154,9 +160,65 @@ namespace std ...@@ -154,9 +160,65 @@ namespace std
recursive_mutex& operator=(const recursive_mutex&); recursive_mutex& operator=(const recursive_mutex&);
}; };
/// timed_mutex
class timed_mutex
{
public:
typedef __gthread_mutex_t native_handle_type;
void lock();
bool try_lock();
template <class _Rep, class _Period>
bool
try_lock_for(const chrono::duration<_Rep, _Period>& __rtime);
// class timed_mutex; template <class _Clock, class _Duration>
// class recursive_timed_mutex; bool
try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime);
void unlock();
native_handle_type
native_handle()
{ return _M_mutex; }
private:
native_handle_type _M_mutex;
timed_mutex(const timed_mutex&);
timed_mutex& operator=(const timed_mutex&);
};
/// recursive_timed_mutex
class recursive_timed_mutex
{
public:
typedef __gthread_mutex_t native_handle_type;
void lock();
bool try_lock();
template <class _Rep, class _Period>
bool
try_lock_for(const chrono::duration<_Rep, _Period>& __rtime);
template <class _Clock, class _Duration>
bool
try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime);
void unlock();
native_handle_type
native_handle()
{ return _M_mutex; }
private:
native_handle_type _M_mutex;
recursive_timed_mutex(const recursive_timed_mutex&);
recursive_timed_mutex& operator=(const recursive_timed_mutex&);
};
/// Do not acquire ownership of the mutex. /// Do not acquire ownership of the mutex.
struct defer_lock_t { }; struct defer_lock_t { };
...@@ -211,19 +273,24 @@ namespace std ...@@ -211,19 +273,24 @@ namespace std
public: public:
typedef _Mutex mutex_type; typedef _Mutex mutex_type;
unique_lock() : _M_device(NULL), _M_owns(false) { } unique_lock()
: _M_device(NULL), _M_owns(false)
{ }
explicit unique_lock(mutex_type& __m) : _M_device(&__m) explicit unique_lock(mutex_type& __m)
: _M_device(&__m)
{ {
lock(); lock();
_M_owns = true; _M_owns = true;
} }
unique_lock(mutex_type& __m, defer_lock_t) unique_lock(mutex_type& __m, defer_lock_t)
: _M_device(&__m), _M_owns(false) { } : _M_device(&__m), _M_owns(false)
{ }
unique_lock(mutex_type& __m, try_to_lock_t) unique_lock(mutex_type& __m, try_to_lock_t)
: _M_device(&__m), _M_owns(_M_device->try_lock()) { } : _M_device(&__m), _M_owns(_M_device->try_lock())
{ }
unique_lock(mutex_type& __m, adopt_lock_t) unique_lock(mutex_type& __m, adopt_lock_t)
: _M_device(&__m), _M_owns(true) : _M_device(&__m), _M_owns(true)
...@@ -231,10 +298,13 @@ namespace std ...@@ -231,10 +298,13 @@ namespace std
// XXX calling thread owns mutex // XXX calling thread owns mutex
} }
unique_lock(mutex_type& __m, const system_time& abs_time); template<typename _Clock, typename _Duration>
unique_lock(mutex_type& __m,
const chrono::time_point<_Clock, _Duration>& __atime);
template<typename _Duration> template<typename _Rep, typename _Period>
unique_lock(mutex_type& __m, const _Duration& rel_time); unique_lock(mutex_type& __m,
const chrono::duration<_Rep, _Period>& __rtime);
~unique_lock() ~unique_lock()
{ {
...@@ -246,7 +316,6 @@ namespace std ...@@ -246,7 +316,6 @@ namespace std
unique_lock& operator=(unique_lock&&); unique_lock& operator=(unique_lock&&);
void void
lock() lock()
{ {
...@@ -276,12 +345,13 @@ namespace std ...@@ -276,12 +345,13 @@ namespace std
throw lock_error(); throw lock_error();
} }
template<typename _Rep, typename _Period>
bool
try_lock_for(const chrono::duration<_Rep, _Period>& __rtime);
template<typename _Duration> template<typename _Clock, typename _Duration>
bool timed_lock(const _Duration& rel_time);
bool bool
timed_lock(const system_time& abs_time); try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime);
void void
swap(unique_lock&& __u); swap(unique_lock&& __u);
...@@ -296,9 +366,11 @@ namespace std ...@@ -296,9 +366,11 @@ namespace std
} }
bool bool
owns_lock() const { return _M_owns; } owns_lock() const
{ return _M_owns; }
operator bool () const { return owns_lock(); } operator bool () const
{ return owns_lock(); }
mutex_type* mutex_type*
mutex() const mutex() const
......
...@@ -39,4 +39,4 @@ void test01() ...@@ -39,4 +39,4 @@ void test01()
m1 = m2; m1 = m2;
} }
// { dg-error "within this context" "" { target *-*-* } 39 } // { dg-error "within this context" "" { target *-*-* } 39 }
// { dg-error "is private" "" { target *-*-* } 102 } // { dg-error "is private" "" { target *-*-* } 108 }
...@@ -38,4 +38,4 @@ void test01() ...@@ -38,4 +38,4 @@ void test01()
mutex_type m2(m1); mutex_type m2(m1);
} }
// { dg-error "within this context" "" { target *-*-* } 38 } // { dg-error "within this context" "" { target *-*-* } 38 }
// { dg-error "is private" "" { target *-*-* } 101 } // { dg-error "is private" "" { target *-*-* } 107 }
...@@ -39,4 +39,4 @@ void test01() ...@@ -39,4 +39,4 @@ void test01()
m1 = m2; m1 = m2;
} }
// { dg-error "within this context" "" { target *-*-* } 39 } // { dg-error "within this context" "" { target *-*-* } 39 }
// { dg-error "is private" "" { target *-*-* } 154 } // { dg-error "is private" "" { target *-*-* } 160 }
...@@ -38,4 +38,4 @@ void test01() ...@@ -38,4 +38,4 @@ void test01()
mutex_type m2(m1); mutex_type m2(m1);
} }
// { dg-error "within this context" "" { target *-*-* } 38 } // { dg-error "within this context" "" { target *-*-* } 38 }
// { dg-error "is private" "" { target *-*-* } 153 } // { dg-error "is private" "" { target *-*-* } 159 }
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