|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77640 - in trunk: boost/thread/detail boost/thread/pthread boost/thread/win32 libs/thread/src/pthread libs/thread/src/win32
From: vicente.botet_at_[hidden]
Date: 2012-03-30 00:46:52
Author: viboes
Date: 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
New Revision: 77640
URL: http://svn.boost.org/trac/boost/changeset/77640
Log:
Thread: Added more noexcept
Text files modified:
trunk/boost/thread/detail/config.hpp | 4 +++
trunk/boost/thread/detail/thread.hpp | 46 ++++++++++++++++++++--------------------
trunk/boost/thread/detail/thread_interruption.hpp | 31 ++++++++++++++++++++------
trunk/boost/thread/pthread/thread_data.hpp | 11 +++++----
trunk/boost/thread/win32/thread_data.hpp | 6 ++--
trunk/libs/thread/src/pthread/thread.cpp | 14 ++++++------
trunk/libs/thread/src/win32/thread.cpp | 16 ++++++------
7 files changed, 75 insertions(+), 53 deletions(-)
Modified: trunk/boost/thread/detail/config.hpp
==============================================================================
--- trunk/boost/thread/detail/config.hpp (original)
+++ trunk/boost/thread/detail/config.hpp 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
@@ -23,6 +23,10 @@
#define BOOST_THREAD_USES_SYSTEM
#endif
+#if defined __IBMCPP__
+#define BOOST_THREAD_DONT_USE_CHRONO
+#endif
+
#if ! defined BOOST_THREAD_DONT_USE_CHRONO && ! defined BOOST_THREAD_DONT_USE_SYSTEM
#define BOOST_THREAD_USES_CHRONO
#endif
Modified: trunk/boost/thread/detail/thread.hpp
==============================================================================
--- trunk/boost/thread/detail/thread.hpp (original)
+++ trunk/boost/thread/detail/thread.hpp 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
@@ -144,7 +144,6 @@
class BOOST_THREAD_DECL thread
{
public:
- //typedef int boost_move_emulation_t;
typedef thread_attributes attributes;
#ifndef BOOST_NO_DELETED_FUNCTIONS
@@ -353,14 +352,14 @@
}
#else
#if defined BOOST_THREAD_USES_MOVE
- thread& operator=(boost::rv<thread>& x)
+ thread& operator=(boost::rv<thread>& x) BOOST_NOEXCEPT
{
thread new_thread(boost::move(x));
swap(new_thread);
return *this;
}
#else
- thread& operator=(detail::thread_move_t<thread> x)
+ thread& operator=(detail::thread_move_t<thread> x) BOOST_NOEXCEPT
{
thread new_thread(x);
swap(new_thread);
@@ -370,30 +369,30 @@
#endif
#if defined BOOST_THREAD_USES_MOVE
- ::boost::rv<thread>& move()
+ ::boost::rv<thread>& move() BOOST_NOEXCEPT
{
return *static_cast< ::boost::rv<thread>* >(this);
}
- const ::boost::rv<thread>& move() const
+ const ::boost::rv<thread>& move() const BOOST_NOEXCEPT
{
return *static_cast<const ::boost::rv<thread>* >(this);
}
- operator ::boost::rv<thread>&()
+ operator ::boost::rv<thread>&() BOOST_NOEXCEPT
{
return *static_cast< ::boost::rv<thread>* >(this);
}
- operator const ::boost::rv<thread>&() const
+ operator const ::boost::rv<thread>&() const BOOST_NOEXCEPT
{
return *static_cast<const ::boost::rv<thread>* >(this);
}
#else
- operator detail::thread_move_t<thread>()
+ operator detail::thread_move_t<thread>() BOOST_NOEXCEPT
{
return move();
}
- detail::thread_move_t<thread> move()
+ detail::thread_move_t<thread> move() BOOST_NOEXCEPT
{
detail::thread_move_t<thread> x(*this);
return x;
@@ -476,7 +475,7 @@
bool joinable() const BOOST_NOEXCEPT;
void join();
#if defined(BOOST_THREAD_PLATFORM_WIN32)
- bool timed_join(const system_time& abs_time);
+ bool timed_join(const system_time& abs_time); // DEPRECATED V2
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
@@ -504,7 +503,8 @@
public:
#else
- bool timed_join(const system_time& abs_time) {
+ bool timed_join(const system_time& abs_time) // DEPRECATED V2
+ {
struct timespec const ts=detail::get_timespec(abs_time);
return do_try_join_until(ts);
}
@@ -547,12 +547,12 @@
#endif
template<typename TimeDuration>
- inline bool timed_join(TimeDuration const& rel_time)
+ inline bool timed_join(TimeDuration const& rel_time) // DEPRECATED V2
{
return timed_join(get_system_time()+rel_time);
}
- void detach();
+ void detach() BOOST_NOEXCEPT;
static unsigned hardware_concurrency() BOOST_NOEXCEPT;
@@ -561,22 +561,22 @@
native_handle_type native_handle();
// backwards compatibility
- bool operator==(const thread& other) const;
- bool operator!=(const thread& other) const;
+ bool operator==(const thread& other) const; // DEPRECATED V2
+ bool operator!=(const thread& other) const; // DEPRECATED V2
static inline void yield() BOOST_NOEXCEPT
{
this_thread::yield();
}
- static inline void sleep(const system_time& xt)
+ static inline void sleep(const system_time& xt) // DEPRECATED V2
{
this_thread::sleep(xt);
}
// extensions
void interrupt();
- bool interruption_requested() const;
+ bool interruption_requested() const BOOST_NOEXCEPT;
};
inline void swap(thread& lhs,thread& rhs) BOOST_NOEXCEPT
@@ -585,17 +585,17 @@
}
#ifndef BOOST_NO_RVALUE_REFERENCES
- inline thread&& move(thread& t)
+ inline thread&& move(thread& t) BOOST_NOEXCEPT
{
return static_cast<thread&&>(t);
}
- inline thread&& move(thread&& t)
+ inline thread&& move(thread&& t) BOOST_NOEXCEPT
{
return static_cast<thread&&>(t);
}
#else
#if !defined BOOST_THREAD_USES_MOVE
- inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> t)
+ inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> t) BOOST_NOEXCEPT
{
return t;
}
@@ -616,10 +616,10 @@
thread::id BOOST_THREAD_DECL get_id() BOOST_NOEXCEPT;
void BOOST_THREAD_DECL interruption_point();
- bool BOOST_THREAD_DECL interruption_enabled();
- bool BOOST_THREAD_DECL interruption_requested();
+ bool BOOST_THREAD_DECL interruption_enabled() BOOST_NOEXCEPT;
+ bool BOOST_THREAD_DECL interruption_requested() BOOST_NOEXCEPT;
- inline BOOST_SYMBOL_VISIBLE void sleep(xtime const& abs_time)
+ inline BOOST_SYMBOL_VISIBLE void sleep(xtime const& abs_time) // DEPRECATED V2
{
sleep(system_time(abs_time));
}
Modified: trunk/boost/thread/detail/thread_interruption.hpp
==============================================================================
--- trunk/boost/thread/detail/thread_interruption.hpp (original)
+++ trunk/boost/thread/detail/thread_interruption.hpp 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
@@ -4,6 +4,9 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// (C) Copyright 2007-9 Anthony Williams
+// (C) Copyright 2012 Vicente J. Botet Escriba
+
+#include <boost/thread/detail/config.hpp>
namespace boost
{
@@ -11,23 +14,37 @@
{
class BOOST_THREAD_DECL disable_interruption
{
+ bool interruption_was_enabled;
+ friend class restore_interruption;
+ public:
+#ifndef BOOST_NO_DELETED_FUNCTIONS
+ disable_interruption(const disable_interruption&) = delete;
+ disable_interruption& operator=(const disable_interruption&) = delete;
+#else
+ private:
disable_interruption(const disable_interruption&);
disable_interruption& operator=(const disable_interruption&);
-
- bool interruption_was_enabled;
- friend class restore_interruption;
public:
- disable_interruption();
- ~disable_interruption();
+#endif
+ disable_interruption() BOOST_NOEXCEPT;
+ ~disable_interruption() BOOST_NOEXCEPT;
};
class BOOST_THREAD_DECL restore_interruption
{
+ public:
+#ifndef BOOST_NO_DELETED_FUNCTIONS
+ restore_interruption(const restore_interruption&) = delete;
+ restore_interruption& operator=(const restore_interruption&) = delete;
+#else
+ private:
restore_interruption(const restore_interruption&);
restore_interruption& operator=(const restore_interruption&);
public:
- explicit restore_interruption(disable_interruption& d);
- ~restore_interruption();
+#endif
+
+ explicit restore_interruption(disable_interruption& d) BOOST_NOEXCEPT;
+ ~restore_interruption() BOOST_NOEXCEPT;
};
}
}
Modified: trunk/boost/thread/pthread/thread_data.hpp
==============================================================================
--- trunk/boost/thread/pthread/thread_data.hpp (original)
+++ trunk/boost/thread/pthread/thread_data.hpp 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
@@ -25,7 +25,7 @@
{
class thread_attributes {
public:
- thread_attributes() {
+ thread_attributes() BOOST_NOEXCEPT {
int res = pthread_attr_init(&val_);
BOOST_VERIFY(!res && "pthread_attr_init failed");
}
@@ -34,7 +34,7 @@
BOOST_VERIFY(!res && "pthread_attr_destroy failed");
}
// stack
- void set_stack_size(std::size_t size) {
+ void set_stack_size(std::size_t size) BOOST_NOEXCEPT {
if (size==0) return;
std::size_t page_size = getpagesize();
#ifdef PTHREAD_STACK_MIN
@@ -45,18 +45,19 @@
BOOST_VERIFY(!res && "pthread_attr_setstacksize failed");
}
- std::size_t get_stack_size() const {
+ std::size_t get_stack_size() const BOOST_NOEXCEPT {
std::size_t size;
int res = pthread_attr_getstacksize(&val_, &size);
BOOST_VERIFY(!res && "pthread_attr_getstacksize failed");
return size;
}
+#define BOOST_THREAD_DEFINES_THREAD_ATTRIBUTES_NATIVE_HANDLE
typedef pthread_attr_t native_handle_type;
- native_handle_type* native_handle() {
+ native_handle_type* native_handle() BOOST_NOEXCEPT {
return &val_;
}
- const native_handle_type* native_handle() const {
+ const native_handle_type* native_handle() const BOOST_NOEXCEPT {
return &val_;
}
Modified: trunk/boost/thread/win32/thread_data.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_data.hpp (original)
+++ trunk/boost/thread/win32/thread_data.hpp 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
@@ -19,18 +19,18 @@
{
class thread_attributes {
public:
- thread_attributes() {
+ thread_attributes() BOOST_NOEXCEPT {
val_.stack_size = 0;
//val_.lpThreadAttributes=0;
}
~thread_attributes() {
}
// stack size
- void set_stack_size(std::size_t size) {
+ void set_stack_size(std::size_t size) BOOST_NOEXCEPT {
val_.stack_size = size;
}
- std::size_t get_stack_size() const {
+ std::size_t get_stack_size() const BOOST_NOEXCEPT {
return val_.stack_size;
}
Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
@@ -358,7 +358,7 @@
}
- void thread::detach()
+ void thread::detach() BOOST_NOEXCEPT
{
detail::thread_data_ptr local_thread_info;
thread_info.swap(local_thread_info);
@@ -560,13 +560,13 @@
}
}
- bool interruption_enabled()
+ bool interruption_enabled() BOOST_NOEXCEPT
{
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
return thread_info && thread_info->interrupt_enabled;
}
- bool interruption_requested()
+ bool interruption_requested() BOOST_NOEXCEPT
{
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
if(!thread_info)
@@ -580,7 +580,7 @@
}
}
- disable_interruption::disable_interruption():
+ disable_interruption::disable_interruption() BOOST_NOEXCEPT:
interruption_was_enabled(interruption_enabled())
{
if(interruption_was_enabled)
@@ -589,7 +589,7 @@
}
}
- disable_interruption::~disable_interruption()
+ disable_interruption::~disable_interruption() BOOST_NOEXCEPT
{
if(detail::get_current_thread_data())
{
@@ -597,7 +597,7 @@
}
}
- restore_interruption::restore_interruption(disable_interruption& d)
+ restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT
{
if(d.interruption_was_enabled)
{
@@ -605,7 +605,7 @@
}
}
- restore_interruption::~restore_interruption()
+ restore_interruption::~restore_interruption() BOOST_NOEXCEPT
{
if(detail::get_current_thread_data())
{
Modified: trunk/libs/thread/src/win32/thread.cpp
==============================================================================
--- trunk/libs/thread/src/win32/thread.cpp (original)
+++ trunk/libs/thread/src/win32/thread.cpp 2012-03-30 00:46:47 EDT (Fri, 30 Mar 2012)
@@ -341,7 +341,7 @@
#endif
- void thread::detach()
+ void thread::detach() BOOST_NOEXCEPT
{
release_handle();
}
@@ -360,7 +360,7 @@
}
}
- bool thread::interruption_requested() const
+ bool thread::interruption_requested() const BOOST_NOEXCEPT
{
detail::thread_data_ptr local_thread_info=(get_thread_info)();
return local_thread_info.get() && (detail::win32::WaitForSingleObject(local_thread_info->interruption_handle,0)==0);
@@ -550,12 +550,12 @@
}
}
- bool interruption_enabled()
+ bool interruption_enabled() BOOST_NOEXCEPT
{
return get_current_thread_data() && get_current_thread_data()->interruption_enabled;
}
- bool interruption_requested()
+ bool interruption_requested() BOOST_NOEXCEPT
{
return get_current_thread_data() && (detail::win32::WaitForSingleObject(get_current_thread_data()->interruption_handle,0)==0);
}
@@ -565,7 +565,7 @@
detail::win32::Sleep(0);
}
- disable_interruption::disable_interruption():
+ disable_interruption::disable_interruption() BOOST_NOEXCEPT:
interruption_was_enabled(interruption_enabled())
{
if(interruption_was_enabled)
@@ -574,7 +574,7 @@
}
}
- disable_interruption::~disable_interruption()
+ disable_interruption::~disable_interruption() BOOST_NOEXCEPT
{
if(get_current_thread_data())
{
@@ -582,7 +582,7 @@
}
}
- restore_interruption::restore_interruption(disable_interruption& d)
+ restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT
{
if(d.interruption_was_enabled)
{
@@ -590,7 +590,7 @@
}
}
- restore_interruption::~restore_interruption()
+ restore_interruption::~restore_interruption() BOOST_NOEXCEPT
{
if(get_current_thread_data())
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk