diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-23 22:17:31 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-23 22:17:31 +0000 |
commit | 16de3083b3f439183ca75a9def825d15963cd6db (patch) | |
tree | 2a71cd4193b35a3043959082880232fa29e4995c /libstdc++-v3 | |
parent | f8daee9bad3067f34c8061fc0fcb2f9dc9525a1b (diff) | |
download | gcc-16de3083b3f439183ca75a9def825d15963cd6db.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138096 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 17 | ||||
-rw-r--r-- | libstdc++-v3/include/std/condition_variable | 75 | ||||
-rw-r--r-- | libstdc++-v3/include/std/mutex | 128 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc | 2 |
7 files changed, 163 insertions, 65 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1f00ddaabfa..1dc05f3cb0e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,14 @@ 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. Holds the lib that defines clock_gettime (-lrt or -lposix4). * src/Makefile.am: Use it. @@ -78,10 +87,10 @@ Update error lineno. * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Update error lineno. - * testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc: - Update error lineno. - * testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc: - Update error lineno. + * testsuite/23_containers/vector/requirements/dr438/ + constructor_1_neg.cc: Update error lineno. + * testsuite/23_containers/vector/requirements/dr438/ + constructor_2_neg.cc: Update error lineno. * testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Update error lineno. * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable index 1dfb7789499..1a7a7cd1f37 100644 --- a/libstdc++-v3/include/std/condition_variable +++ b/libstdc++-v3/include/std/condition_variable @@ -44,8 +44,14 @@ namespace std { - // XXX - class system_time; + namespace chrono + { + template<typename _Rep, typename _Period> + struct duration; + + template<typename _Clock, typename _Duration> + struct time_point; + } /// condition_variable class condition_variable @@ -78,22 +84,27 @@ namespace std wait(__lock); } - template<typename _Duration> - bool - timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime); - - bool - timed_wait(unique_lock<mutex>& __lock, const system_time& __atime); - - template<typename _Predicate> - bool - timed_wait(unique_lock<mutex>& __lock, const system_time& __atime, - _Predicate pred); - - template<typename _Duration, typename _Predicate> + template<typename _Clock, typename _Duration> bool - timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime, - _Predicate pred); + wait_until(unique_lock<mutex>& __lock, + const chrono::time_point<_Clock, _Duration>& __atime); + + template<typename _Clock, typename _Duration, typename _Predicate> + bool + wait_until(unique_lock<mutex>& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p); + + template<typename _Rep, typename _Period> + bool + wait_for(unique_lock<mutex>& __lock, + const chrono::duration<_Rep, _Period>& __rtime); + + template<typename _Rep, typename _Period, typename _Predicate> + bool + wait_for(unique_lock<mutex>& __lock, + const chrono::duration<_Rep, _Period>& __rtime, + _Predicate __p); native_handle_type native_handle() { return _M_cond; } @@ -132,21 +143,27 @@ namespace std void wait(_Lock& __lock, _Predicate __p); - template<typename _Lock> - bool - timed_wait(_Lock& __lock, const system_time& __atime); - - template<typename _Lock, typename _Duration> - bool - timed_wait(_Lock& __lock, const _Duration& __rtime); - - template<typename _Lock, typename _Predicate> + template<typename _Lock, typename _Clock, typename _Duration> bool - timed_wait(_Lock& __lock, const system_time& __atime, _Predicate __p); + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime); - template<typename _Lock, typename _Duration, typename _Predicate> + template<typename _Lock, typename _Clock, + typename _Duration, typename _Predicate> bool - timed_wait(_Lock& __lock, const _Duration& __rtime, _Predicate __p); + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p); + + template<typename _Lock, typename _Rep, typename _Period> + bool + wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime); + + template<typename _Lock, typename _Rep, + typename _Period, typename _Predicate> + bool + wait_for(_Lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime, _Predicate __p); native_handle_type native_handle() { return _M_cond; } diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index e4ba94def11..779394a5891 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -48,8 +48,14 @@ namespace std { - // XXX - class system_time; + namespace chrono + { + template<typename _Rep, typename _Period> + struct duration; + + template<typename _Clock, typename _Duration> + struct time_point; + } /// mutex class mutex @@ -74,22 +80,22 @@ namespace std int __e = __gthread_mutex_lock(&_M_mutex); // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) - if (__e) - __throw_system_error(__e); + if (__e) + __throw_system_error(__e); } bool try_lock() { - // XXX EINVAL, EAGAIN, EBUSY - return !__gthread_mutex_trylock(&_M_mutex); + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_mutex_trylock(&_M_mutex); } void unlock() { // XXX EINVAL, EAGAIN, EPERM - __gthread_mutex_unlock(&_M_mutex); + __gthread_mutex_unlock(&_M_mutex); } native_handle_type @@ -102,7 +108,6 @@ namespace std mutex& operator=(const mutex&); }; - /// recursive_mutex class recursive_mutex { @@ -126,8 +131,8 @@ namespace std int __e = __gthread_recursive_mutex_lock(&_M_mutex); // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) - if (__e) - __throw_system_error(__e); + if (__e) + __throw_system_error(__e); } bool @@ -145,7 +150,8 @@ namespace std } native_handle_type - native_handle() { return _M_mutex; } + native_handle() + { return _M_mutex; } private: native_handle_type _M_mutex; @@ -154,9 +160,65 @@ namespace std 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); + + template <class _Clock, class _Duration> + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime); + + void unlock(); - // class timed_mutex; - // class recursive_timed_mutex; + 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. struct defer_lock_t { }; @@ -211,19 +273,24 @@ namespace std public: 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(); _M_owns = true; } 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) - : _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) : _M_device(&__m), _M_owns(true) @@ -231,10 +298,13 @@ namespace std // 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> - unique_lock(mutex_type& __m, const _Duration& rel_time); + template<typename _Rep, typename _Period> + unique_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rtime); ~unique_lock() { @@ -246,7 +316,6 @@ namespace std unique_lock& operator=(unique_lock&&); - void lock() { @@ -276,12 +345,13 @@ namespace std throw lock_error(); } + template<typename _Rep, typename _Period> + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime); - template<typename _Duration> - bool timed_lock(const _Duration& rel_time); - - bool - timed_lock(const system_time& abs_time); + template<typename _Clock, typename _Duration> + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime); void swap(unique_lock&& __u); @@ -296,9 +366,11 @@ namespace std } 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() const diff --git a/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc index f365d1167c1..8c66bb53cd7 100644 --- a/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc @@ -39,4 +39,4 @@ void test01() m1 = m2; } // { dg-error "within this context" "" { target *-*-* } 39 } -// { dg-error "is private" "" { target *-*-* } 102 } +// { dg-error "is private" "" { target *-*-* } 108 } diff --git a/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc index d0a91025b54..666506a36b1 100644 --- a/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc @@ -38,4 +38,4 @@ void test01() mutex_type m2(m1); } // { dg-error "within this context" "" { target *-*-* } 38 } -// { dg-error "is private" "" { target *-*-* } 101 } +// { dg-error "is private" "" { target *-*-* } 107 } diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc index 2e057104ec4..b7e27847667 100644 --- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc @@ -39,4 +39,4 @@ void test01() m1 = m2; } // { dg-error "within this context" "" { target *-*-* } 39 } -// { dg-error "is private" "" { target *-*-* } 154 } +// { dg-error "is private" "" { target *-*-* } 160 } diff --git a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc index a98e73333e5..2d20cb98c3d 100644 --- a/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc @@ -38,4 +38,4 @@ void test01() mutex_type m2(m1); } // { dg-error "within this context" "" { target *-*-* } 38 } -// { dg-error "is private" "" { target *-*-* } 153 } +// { dg-error "is private" "" { target *-*-* } 159 } |