thread: Use noexcept throughout per the FDIS.
2011-05-25 Paolo Carlini <paolo.carlini@oracle.com> * include/std/thread: Use noexcept throughout per the FDIS. * include/std/mutex: Likewise. From-SVN: r174202
This commit is contained in:
parent
bc7f13bf15
commit
7f0d79d514
|
@ -1,3 +1,8 @@
|
||||||
|
2011-05-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* include/std/thread: Use noexcept throughout per the FDIS.
|
||||||
|
* include/std/mutex: Likewise.
|
||||||
|
|
||||||
2011-05-24 Paolo Carlini <paolo.carlini@oracle.com>
|
2011-05-24 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* testsuite/20_util/duration/arithmetic/dr2020.cc: Fix typo.
|
* testsuite/20_util/duration/arithmetic/dr2020.cc: Fix typo.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// <mutex> -*- C++ -*-
|
// <mutex> -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||||
// Free Software Foundation, Inc.
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
@ -70,9 +70,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
typedef __native_type* native_handle_type;
|
typedef __native_type* native_handle_type;
|
||||||
|
|
||||||
#ifdef __GTHREAD_MUTEX_INIT
|
#ifdef __GTHREAD_MUTEX_INIT
|
||||||
constexpr mutex() : _M_mutex(__GTHREAD_MUTEX_INIT) { }
|
constexpr mutex() noexcept : _M_mutex(__GTHREAD_MUTEX_INIT) { }
|
||||||
#else
|
#else
|
||||||
mutex()
|
mutex() noexcept
|
||||||
{
|
{
|
||||||
// XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
|
// XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
|
||||||
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
|
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
|
||||||
|
@ -95,7 +95,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
try_lock()
|
try_lock() noexcept
|
||||||
{
|
{
|
||||||
// XXX EINVAL, EAGAIN, EBUSY
|
// XXX EINVAL, EAGAIN, EBUSY
|
||||||
return !__gthread_mutex_trylock(&_M_mutex);
|
return !__gthread_mutex_trylock(&_M_mutex);
|
||||||
|
@ -188,7 +188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
try_lock()
|
try_lock() noexcept
|
||||||
{
|
{
|
||||||
// XXX EINVAL, EAGAIN, EBUSY
|
// XXX EINVAL, EAGAIN, EBUSY
|
||||||
return !__gthread_recursive_mutex_trylock(&_M_mutex);
|
return !__gthread_recursive_mutex_trylock(&_M_mutex);
|
||||||
|
@ -247,7 +247,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
try_lock()
|
try_lock() noexcept
|
||||||
{
|
{
|
||||||
// XXX EINVAL, EAGAIN, EBUSY
|
// XXX EINVAL, EAGAIN, EBUSY
|
||||||
return !__gthread_mutex_trylock(&_M_mutex);
|
return !__gthread_mutex_trylock(&_M_mutex);
|
||||||
|
@ -354,7 +354,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
try_lock()
|
try_lock() noexcept
|
||||||
{
|
{
|
||||||
// XXX EINVAL, EAGAIN, EBUSY
|
// XXX EINVAL, EAGAIN, EBUSY
|
||||||
return !__gthread_recursive_mutex_trylock(&_M_mutex);
|
return !__gthread_recursive_mutex_trylock(&_M_mutex);
|
||||||
|
@ -464,7 +464,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
public:
|
public:
|
||||||
typedef _Mutex mutex_type;
|
typedef _Mutex mutex_type;
|
||||||
|
|
||||||
unique_lock()
|
unique_lock() noexcept
|
||||||
: _M_device(0), _M_owns(false)
|
: _M_device(0), _M_owns(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
_M_owns = true;
|
_M_owns = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_lock(mutex_type& __m, defer_lock_t)
|
unique_lock(mutex_type& __m, defer_lock_t) noexcept
|
||||||
: _M_device(&__m), _M_owns(false)
|
: _M_device(&__m), _M_owns(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -510,14 +510,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
unique_lock(const unique_lock&) = delete;
|
unique_lock(const unique_lock&) = delete;
|
||||||
unique_lock& operator=(const unique_lock&) = delete;
|
unique_lock& operator=(const unique_lock&) = delete;
|
||||||
|
|
||||||
unique_lock(unique_lock&& __u)
|
unique_lock(unique_lock&& __u) noexcept
|
||||||
: _M_device(__u._M_device), _M_owns(__u._M_owns)
|
: _M_device(__u._M_device), _M_owns(__u._M_owns)
|
||||||
{
|
{
|
||||||
__u._M_device = 0;
|
__u._M_device = 0;
|
||||||
__u._M_owns = false;
|
__u._M_owns = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_lock& operator=(unique_lock&& __u)
|
unique_lock& operator=(unique_lock&& __u) noexcept
|
||||||
{
|
{
|
||||||
if(_M_owns)
|
if(_M_owns)
|
||||||
unlock();
|
unlock();
|
||||||
|
@ -601,14 +601,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(unique_lock& __u)
|
swap(unique_lock& __u) noexcept
|
||||||
{
|
{
|
||||||
std::swap(_M_device, __u._M_device);
|
std::swap(_M_device, __u._M_device);
|
||||||
std::swap(_M_owns, __u._M_owns);
|
std::swap(_M_owns, __u._M_owns);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_type*
|
mutex_type*
|
||||||
release()
|
release() noexcept
|
||||||
{
|
{
|
||||||
mutex_type* __ret = _M_device;
|
mutex_type* __ret = _M_device;
|
||||||
_M_device = 0;
|
_M_device = 0;
|
||||||
|
@ -617,14 +617,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
owns_lock() const
|
owns_lock() const noexcept
|
||||||
{ return _M_owns; }
|
{ return _M_owns; }
|
||||||
|
|
||||||
explicit operator bool() const
|
explicit operator bool() const noexcept
|
||||||
{ return owns_lock(); }
|
{ return owns_lock(); }
|
||||||
|
|
||||||
mutex_type*
|
mutex_type*
|
||||||
mutex() const
|
mutex() const noexcept
|
||||||
{ return _M_device; }
|
{ return _M_device; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -634,7 +634,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
template<typename _Mutex>
|
template<typename _Mutex>
|
||||||
inline void
|
inline void
|
||||||
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y)
|
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept
|
||||||
{ __x.swap(__y); }
|
{ __x.swap(__y); }
|
||||||
|
|
||||||
template<int _Idx>
|
template<int _Idx>
|
||||||
|
@ -759,7 +759,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
__native_type _M_once;
|
__native_type _M_once;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr once_flag() : _M_once(__GTHREAD_ONCE_INIT) { }
|
constexpr once_flag() noexcept : _M_once(__GTHREAD_ONCE_INIT) { }
|
||||||
|
|
||||||
once_flag(const once_flag&) = delete;
|
once_flag(const once_flag&) = delete;
|
||||||
once_flag& operator=(const once_flag&) = delete;
|
once_flag& operator=(const once_flag&) = delete;
|
||||||
|
|
|
@ -72,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
native_handle_type _M_thread;
|
native_handle_type _M_thread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
id() : _M_thread() { }
|
id() noexcept : _M_thread() { }
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
id(native_handle_type __id) : _M_thread(__id) { }
|
id(native_handle_type __id) : _M_thread(__id) { }
|
||||||
|
@ -82,11 +82,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
friend class hash<thread::id>;
|
friend class hash<thread::id>;
|
||||||
|
|
||||||
friend bool
|
friend bool
|
||||||
operator==(thread::id __x, thread::id __y)
|
operator==(thread::id __x, thread::id __y) noexcept
|
||||||
{ return __gthread_equal(__x._M_thread, __y._M_thread); }
|
{ return __gthread_equal(__x._M_thread, __y._M_thread); }
|
||||||
|
|
||||||
friend bool
|
friend bool
|
||||||
operator<(thread::id __x, thread::id __y)
|
operator<(thread::id __x, thread::id __y) noexcept
|
||||||
{ return __x._M_thread < __y._M_thread; }
|
{ return __x._M_thread < __y._M_thread; }
|
||||||
|
|
||||||
template<class _CharT, class _Traits>
|
template<class _CharT, class _Traits>
|
||||||
|
@ -121,11 +121,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
id _M_id;
|
id _M_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
thread() = default;
|
thread() noexcept = default;
|
||||||
thread(thread&) = delete;
|
thread(thread&) = delete;
|
||||||
thread(const thread&) = delete;
|
thread(const thread&) = delete;
|
||||||
|
|
||||||
thread(thread&& __t)
|
thread(thread&& __t) noexcept
|
||||||
{ swap(__t); }
|
{ swap(__t); }
|
||||||
|
|
||||||
template<typename _Callable, typename... _Args>
|
template<typename _Callable, typename... _Args>
|
||||||
|
@ -145,7 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
thread& operator=(const thread&) = delete;
|
thread& operator=(const thread&) = delete;
|
||||||
|
|
||||||
thread& operator=(thread&& __t)
|
thread& operator=(thread&& __t) noexcept
|
||||||
{
|
{
|
||||||
if (joinable())
|
if (joinable())
|
||||||
std::terminate();
|
std::terminate();
|
||||||
|
@ -154,11 +154,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(thread& __t)
|
swap(thread& __t) noexcept
|
||||||
{ std::swap(_M_id, __t._M_id); }
|
{ std::swap(_M_id, __t._M_id); }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
joinable() const
|
joinable() const noexcept
|
||||||
{ return !(_M_id == id()); }
|
{ return !(_M_id == id()); }
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -168,7 +168,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
detach();
|
detach();
|
||||||
|
|
||||||
thread::id
|
thread::id
|
||||||
get_id() const
|
get_id() const noexcept
|
||||||
{ return _M_id; }
|
{ return _M_id; }
|
||||||
|
|
||||||
/** @pre thread is joinable
|
/** @pre thread is joinable
|
||||||
|
@ -179,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
// Returns a value that hints at the number of hardware thread contexts.
|
// Returns a value that hints at the number of hardware thread contexts.
|
||||||
static unsigned int
|
static unsigned int
|
||||||
hardware_concurrency()
|
hardware_concurrency() noexcept
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -198,23 +198,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
inline thread::_Impl_base::~_Impl_base() = default;
|
inline thread::_Impl_base::~_Impl_base() = default;
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
swap(thread& __x, thread& __y)
|
swap(thread& __x, thread& __y) noexcept
|
||||||
{ __x.swap(__y); }
|
{ __x.swap(__y); }
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(thread::id __x, thread::id __y)
|
operator!=(thread::id __x, thread::id __y) noexcept
|
||||||
{ return !(__x == __y); }
|
{ return !(__x == __y); }
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
operator<=(thread::id __x, thread::id __y)
|
operator<=(thread::id __x, thread::id __y) noexcept
|
||||||
{ return !(__y < __x); }
|
{ return !(__y < __x); }
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
operator>(thread::id __x, thread::id __y)
|
operator>(thread::id __x, thread::id __y) noexcept
|
||||||
{ return __y < __x; }
|
{ return __y < __x; }
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
operator>=(thread::id __x, thread::id __y)
|
operator>=(thread::id __x, thread::id __y) noexcept
|
||||||
{ return !(__x < __y); }
|
{ return !(__x < __y); }
|
||||||
|
|
||||||
// DR 889.
|
// DR 889.
|
||||||
|
@ -250,12 +250,12 @@ _GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
|
||||||
/// get_id
|
/// get_id
|
||||||
inline thread::id
|
inline thread::id
|
||||||
get_id() { return thread::id(__gthread_self()); }
|
get_id() noexcept { return thread::id(__gthread_self()); }
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_SCHED_YIELD
|
#ifdef _GLIBCXX_USE_SCHED_YIELD
|
||||||
/// yield
|
/// yield
|
||||||
inline void
|
inline void
|
||||||
yield()
|
yield() noexcept
|
||||||
{ __gthread_yield(); }
|
{ __gthread_yield(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue