Commit 6e4a660f by Paolo Carlini Committed by Paolo Carlini

revert: condition_variable (condition_variable_any:: wait<>(_Lock&)): Provide definition.

2010-01-31  Paolo Carlini  <paolo.carlini@oracle.com>

	Revert last changes. Also revert, among the previous changes:
	* include/std/condition_variable (condition_variable_any::
	wait<>(_Lock&)): Provide definition.

From-SVN: r156403
parent b0a69d20
2010-01-31 Paolo Carlini <paolo.carlini@oracle.com>
Revert last changes. Also revert, among the previous changes:
* include/std/condition_variable (condition_variable_any::
wait<>(_Lock&)): Provide definition.
2010-01-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/condition_variable (condition_variable_any::
......
......@@ -165,7 +165,6 @@ namespace std
// Like above, only mutex may not have try_lock.
class condition_variable_any
{
typedef chrono::system_clock __clock_t;
typedef __gthread_cond_t __native_type;
__native_type _M_cond;
......@@ -186,13 +185,7 @@ namespace std
template<typename _Lock>
void
wait(_Lock& __lock)
{
int __e = __gthread_cond_wait(&_M_cond,
__lock.mutex()->native_handle());
if (__e)
__throw_system_error(__e);
}
wait(_Lock& __lock);
template<typename _Lock, typename _Predicate>
void
......@@ -202,25 +195,10 @@ namespace std
wait(__lock);
}
template<typename _Lock, typename _Duration>
cv_status
wait_until(_Lock& __lock,
const chrono::time_point<__clock_t, _Duration>& __atime)
{ return __wait_until_impl(__lock, __atime); }
template<typename _Lock, typename _Clock, typename _Duration>
cv_status
wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __atime)
{
// DR 887 - Sync unknown clock to known clock.
const typename _Clock::time_point __c_entry = _Clock::now();
const __clock_t::time_point __s_entry = __clock_t::now();
const chrono::nanoseconds __delta = __atime - __c_entry;
const __clock_t::time_point __s_atime = __s_entry + __delta;
return __wait_until_impl(__lock, __s_atime);
}
const chrono::time_point<_Clock, _Duration>& __atime);
template<typename _Lock, typename _Clock,
typename _Duration, typename _Predicate>
......@@ -248,31 +226,6 @@ namespace std
native_handle_type
native_handle()
{ return &_M_cond; }
private:
template<typename _Lock, typename _Clock, typename _Duration>
cv_status
__wait_until_impl(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __atime)
{
chrono::time_point<__clock_t, chrono::seconds> __s =
chrono::time_point_cast<chrono::seconds>(__atime);
chrono::nanoseconds __ns =
chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
__gthread_time_t __ts =
{
static_cast<std::time_t>(__s.time_since_epoch().count()),
static_cast<long>(__ns.count())
};
__gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
&__ts);
return (_Clock::now() < __atime
? cv_status::no_timeout : cv_status::timeout);
}
};
// @} group condition_variables
......
......@@ -32,4 +32,4 @@ void test01()
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 179 }
// { dg-error "deleted function" "" { target *-*-* } 178 }
......@@ -31,4 +31,4 @@ void test01()
}
// { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "deleted function" "" { target *-*-* } 178 }
// { dg-error "deleted function" "" { target *-*-* } 177 }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// 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
// 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 <chrono>
#include <condition_variable>
#include <system_error>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
try
{
std::chrono::microseconds ms(500);
std::condition_variable_any c1;
std::mutex m;
std::unique_lock<std::mutex> l(m);
auto then = std::chrono::monotonic_clock::now();
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() );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
}
int main()
{
test01();
return 0;
}
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