// <mutex> -*- C++ -*-
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
#pragma GCC system_header
#ifndef __GXX_EXPERIMENTAL_CXX0X__
-# include <c++0x_warning.h>
+# include <bits/c++0x_warning.h>
#else
#include <tuple>
extern const try_to_lock_t try_to_lock;
extern const adopt_lock_t adopt_lock;
- /**
- * @brief Thrown to indicate errors with lock operations.
- *
- * @ingroup exceptions
- */
- class lock_error : public exception
- {
- public:
- virtual const char*
- what() const throw();
- };
-
/// @brief Scoped lock idiom.
// Acquire the mutex here with a constructor call, then release with
// the destructor call in accordance with RAII style.
}
void
- swap(unique_lock&& __u)
+ swap(unique_lock& __u)
{
std::swap(_M_device, __u._M_device);
std::swap(_M_owns, __u._M_owns);
owns_lock() const
{ return _M_owns; }
- /* explicit */ operator bool () const
+ explicit operator bool() const
{ return owns_lock(); }
mutex_type*
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y)
{ __x.swap(__y); }
- template<typename _Mutex>
- inline void
- swap(unique_lock<_Mutex>&& __x, unique_lock<_Mutex>& __y)
- { __x.swap(__y); }
-
- template<typename _Mutex>
- inline void
- swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>&& __y)
- { __x.swap(__y); }
-
template<int _Idx>
struct __unlock_impl
{
#else
extern function<void()> __once_functor;
- extern unique_lock<mutex>&
- __get_once_functor_lock();
+ extern void
+ __set_once_functor_lock_ptr(unique_lock<mutex>*);
+
+ extern mutex&
+ __get_once_mutex();
#endif
extern "C" void __once_proxy();
call_once(once_flag& __once, _Callable __f, _Args&&... __args)
{
#ifdef _GLIBCXX_HAVE_TLS
- auto __bound_functor = bind(__f, __args...);
+ auto __bound_functor = std::bind<void>(__f, __args...);
__once_callable = &__bound_functor;
__once_call = &__once_call_impl<decltype(__bound_functor)>;
#else
- unique_lock<mutex>& __functor_lock = __get_once_functor_lock();
- __functor_lock.lock();
- __once_functor = bind(__f, __args...);
+ unique_lock<mutex> __functor_lock(__get_once_mutex());
+ __once_functor = std::bind<void>(__f, __args...);
+ __set_once_functor_lock_ptr(&__functor_lock);
#endif
int __e = __gthread_once(&(__once._M_once), &__once_proxy);
#ifndef _GLIBCXX_HAVE_TLS
if (__functor_lock)
- __functor_lock.unlock();
+ __set_once_functor_lock_ptr(0);
#endif
if (__e)