* include/std/condition_variable (enum class cv_status): Add and
use it throughout, per N3000.
(condition_variable_any::wait<>(_Lock&), wait<>(_Lock&, _Predicate),
wait_until<>(_Lock&, const chrono::time_point<>&, _Predicate)):
Provide definitions.
* src/condition_variable.cc (condition_variable_any::notify_one,
condition_variable_any::notify_all): Likewise.
* config/abi/pre/gnu.ver: Export.
* testsuite/30_threads/condition_variable_any/requirements/
typedefs.cc: New.
* testsuite/30_threads/condition_variable_any/requirements/
standard_layout.cc: Likewise.
* testsuite/30_threads/condition_variable/members/1.cc: Adjust.
* testsuite/30_threads/condition_variable/members/2.cc: Likewise.
* testsuite/30_threads/condition_variable/cons/assign_neg.cc: Adjust
dg-error line numbers.
* testsuite/30_threads/condition_variable/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/condition_variable_any/cons/assign_neg.cc:
Likewise.
* testsuite/30_threads/condition_variable_any/cons/copy_neg.cc:
Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156358
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-01-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/std/condition_variable (enum class cv_status): Add and
+ use it throughout, per N3000.
+ (condition_variable_any::wait<>(_Lock&), wait<>(_Lock&, _Predicate),
+ wait_until<>(_Lock&, const chrono::time_point<>&, _Predicate)):
+ Provide definitions.
+ * src/condition_variable.cc (condition_variable_any::notify_one,
+ condition_variable_any::notify_all): Likewise.
+ * config/abi/pre/gnu.ver: Export.
+ * testsuite/30_threads/condition_variable_any/requirements/
+ typedefs.cc: New.
+ * testsuite/30_threads/condition_variable_any/requirements/
+ standard_layout.cc: Likewise.
+ * testsuite/30_threads/condition_variable/members/1.cc: Adjust.
+ * testsuite/30_threads/condition_variable/members/2.cc: Likewise.
+ * testsuite/30_threads/condition_variable/cons/assign_neg.cc: Adjust
+ dg-error line numbers.
+ * testsuite/30_threads/condition_variable/cons/copy_neg.cc: Likewise.
+ * testsuite/30_threads/condition_variable_any/cons/assign_neg.cc:
+ Likewise.
+ * testsuite/30_threads/condition_variable_any/cons/copy_neg.cc:
+ Likewise.
+
2010-01-28 François Dumont <francois.cppdevs@free.fr>
* include/bits/stl_algobase.h (struct __iter_base): Add.
# std::time_get::_M_extract_wday_or_month
_ZNKSt8time_getI[cw]St19istreambuf_iteratorI[cw]St11char_traitsI[cw]EEE24_M_extract_wday_or_month*;
+ # condition_variable_any::notify_*
+ _ZNSt22condition_variable_any10notify_allEv;
+ _ZNSt22condition_variable_any10notify_oneEv;
+
} GLIBCXX_3.4.13;
# Symbols in the support library (libsupc++) have their own tag.
// <condition_variable> -*- C++ -*-
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
* @{
*/
+ /// cv_status
+ enum class cv_status { no_timeout, timeout };
+
/// condition_variable
class condition_variable
{
}
template<typename _Duration>
- bool
+ cv_status
wait_until(unique_lock<mutex>& __lock,
const chrono::time_point<__clock_t, _Duration>& __atime)
{ return __wait_until_impl(__lock, __atime); }
template<typename _Clock, typename _Duration>
- bool
+ cv_status
wait_until(unique_lock<mutex>& __lock,
const chrono::time_point<_Clock, _Duration>& __atime)
{
_Predicate __p)
{
while (!__p())
- if (!wait_until(__lock, __atime))
+ if (wait_until(__lock, __atime) == cv_status::timeout)
return __p();
-
return true;
}
template<typename _Rep, typename _Period>
- bool
+ cv_status
wait_for(unique_lock<mutex>& __lock,
const chrono::duration<_Rep, _Period>& __rtime)
{ return wait_until(__lock, __clock_t::now() + __rtime); }
private:
template<typename _Clock, typename _Duration>
- bool
+ cv_status
__wait_until_impl(unique_lock<mutex>& __lock,
const chrono::time_point<_Clock, _Duration>& __atime)
{
__gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
&__ts);
- return _Clock::now() < __atime;
+ return (_Clock::now() < __atime
+ ? cv_status::no_timeout : cv_status::timeout);
}
};
template<typename _Lock>
void
- wait(_Lock& __lock);
+ wait(_Lock& __lock)
+ {
+ int __e = __gthread_cond_wait(&_M_cond,
+ __lock.mutex()->native_handle());
+ if (__e)
+ __throw_system_error(__e);
+ }
template<typename _Lock, typename _Predicate>
void
- wait(_Lock& __lock, _Predicate __p);
+ wait(_Lock& __lock, _Predicate __p)
+ {
+ while (!__p())
+ wait(__lock);
+ }
template<typename _Lock, typename _Clock, typename _Duration>
- bool
+ cv_status
wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __atime);
bool
wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __atime,
- _Predicate __p);
+ _Predicate __p)
+ {
+ while (!__p())
+ if (wait_until(__lock, __atime) == cv_status::timeout)
+ return __p();
+ return true;
+ }
template<typename _Lock, typename _Rep, typename _Period>
- bool
+ cv_status
wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime);
template<typename _Lock, typename _Rep,
{
__gthread_cond_destroy(&_M_cond);
}
+
+ void
+ condition_variable_any::notify_one()
+ {
+ int __e = __gthread_cond_signal(&_M_cond);
+
+ // XXX not in spec
+ // EINVAL
+ if (__e)
+ __throw_system_error(__e);
+ }
+
+ void
+ condition_variable_any::notify_all()
+ {
+ int __e = __gthread_cond_broadcast(&_M_cond);
+
+ // XXX not in spec
+ // EINVAL
+ if (__e)
+ __throw_system_error(__e);
+ }
}
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
}
// { dg-error "used here" "" { target *-*-* } 31 }
-// { dg-error "deleted function" "" { target *-*-* } 67 }
+// { dg-error "deleted function" "" { target *-*-* } 70 }
}
// { dg-error "used here" "" { target *-*-* } 30 }
-// { dg-error "deleted function" "" { target *-*-* } 66 }
+// { dg-error "deleted function" "" { target *-*-* } 69 }
std::unique_lock<std::mutex> l(m);
auto then = std::chrono::system_clock::now();
- bool result = c1.wait_for(l, ms);
- VERIFY( !result );
+ std::cv_status result = c1.wait_for(l, ms);
+ VERIFY( result == std::cv_status::timeout );
VERIFY( (std::chrono::system_clock::now() - then) >= ms );
VERIFY( l.owns_lock() );
}
std::unique_lock<std::mutex> l(m);
auto then = std::chrono::monotonic_clock::now();
- bool result = c1.wait_until(l, then + ms);
- VERIFY( !result );
+ std::cv_status result = c1.wait_until(l, then + ms);
+ VERIFY( result == std::cv_status::timeout );
VERIFY( (std::chrono::monotonic_clock::now() - then) >= ms );
VERIFY( l.owns_lock() );
}
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
}
// { dg-error "used here" "" { target *-*-* } 31 }
-// { dg-error "deleted function" "" { target *-*-* } 175 }
+// { dg-error "deleted function" "" { target *-*-* } 178 }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
}
// { dg-error "used here" "" { target *-*-* } 30 }
-// { dg-error "deleted function" "" { target *-*-* } 174 }
+// { dg-error "deleted function" "" { target *-*-* } 177 }
--- /dev/null
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <condition_variable>
+#include <testsuite_common_types.h>
+
+void test01()
+{
+ __gnu_test::standard_layout test;
+ test.operator()<std::condition_variable_any>();
+}
--- /dev/null
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <condition_variable>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::condition_variable_any test_type;
+ typedef test_type::native_handle_type type;
+}