condition_variable: Update to N2691 WD.
authorChris Fairles <chris.fairles@gmail.com>
Wed, 23 Jul 2008 22:17:31 +0000 (22:17 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 23 Jul 2008 22:17:31 +0000 (22:17 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/condition_variable
libstdc++-v3/include/std/mutex
libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc
libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc

index 1f00ddaabfa0561cdc4063b708aedf2436f8e990..1dc05f3cb0ec9627491789e9c2508e9b8f10486b 100644 (file)
@@ -1,3 +1,12 @@
+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.
        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:
index 1dfb77894995a7d98d8a7f862c4c55290909b0d8..1a7a7cd1f37d14549bb8aa54d5ff20ff77e10d1a 100644 (file)
 
 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; }
index e4ba94def11898ae6aec2ba1df7d144ed648fee5..779394a5891416939c82fd9b4f6ed1751c2ecce1 100644 (file)
 
 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
index f365d1167c1c5b7e14ed3258b19e42d1005d17ef..8c66bb53cd7f2c0a9bc275c86896d3e4e21f7446 100644 (file)
@@ -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 } 
index d0a91025b54d9db177f73486608c039cc1021891..666506a36b14009b211d77fae5c7df13e7fa24a6 100644 (file)
@@ -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 } 
index 2e057104ec428eeaf909d6e3701b99f2e4f3b1ec..b7e27847667f0326a6331451f13648b0becb1b64 100644 (file)
@@ -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 } 
index a98e73333e576921f9e31e90b3ee1c901bfc7d8f..2d20cb98c3df149fa9c9f1cf416bbd0c39f7a174 100644 (file)
@@ -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 }