summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-19 20:22:58 (GMT)
committerTobias Markmann <tm@ayena.de>2014-10-20 13:49:33 (GMT)
commit6b22dfcf59474dd016a0355a3102a1dd3692d92c (patch)
tree2b1fd33be433a91e81fee84fdc2bf1b52575d934 /3rdParty/Boost/src/boost/thread/detail/thread_group.hpp
parent38b0cb785fea8eae5e48fae56440695fdfd10ee1 (diff)
downloadswift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.zip
swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.tar.bz2
Update Boost in 3rdParty to version 1.56.0.
This updates Boost in our 3rdParty directory to version 1.56.0. Updated our update.sh script to stop on error. Changed error reporting in SwiftTools/CrashReporter.cpp to SWIFT_LOG due to missing include of <iostream> with newer Boost. Change-Id: I4b35c77de951333979a524097f35f5f83d325edc
Diffstat (limited to '3rdParty/Boost/src/boost/thread/detail/thread_group.hpp')
-rw-r--r--3rdParty/Boost/src/boost/thread/detail/thread_group.hpp64
1 files changed, 55 insertions, 9 deletions
diff --git a/3rdParty/Boost/src/boost/thread/detail/thread_group.hpp b/3rdParty/Boost/src/boost/thread/detail/thread_group.hpp
index f1ccdf8..69ce991 100644
--- a/3rdParty/Boost/src/boost/thread/detail/thread_group.hpp
+++ b/3rdParty/Boost/src/boost/thread/detail/thread_group.hpp
@@ -8,6 +8,7 @@
#include <list>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/mutex.hpp>
+#include <boost/thread/lock_guard.hpp>
#include <boost/config/abi_prefix.hpp>
@@ -22,7 +23,7 @@ namespace boost
{
private:
thread_group(thread_group const&);
- thread_group& operator=(thread_group const&);
+ thread_group& operator=(thread_group const&);
public:
thread_group() {}
~thread_group()
@@ -35,6 +36,41 @@ namespace boost
}
}
+ bool is_this_thread_in()
+ {
+ thread::id id = this_thread::get_id();
+ boost::shared_lock<shared_mutex> guard(m);
+ for(std::list<thread*>::iterator it=threads.begin(),end=threads.end();
+ it!=end;
+ ++it)
+ {
+ if ((*it)->get_id() == id)
+ return true;
+ }
+ return false;
+ }
+
+ bool is_thread_in(thread* thrd)
+ {
+ if(thrd)
+ {
+ thread::id id = thrd->get_id();
+ boost::shared_lock<shared_mutex> guard(m);
+ for(std::list<thread*>::iterator it=threads.begin(),end=threads.end();
+ it!=end;
+ ++it)
+ {
+ if ((*it)->get_id() == id)
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
template<typename F>
thread* create_thread(F threadfunc)
{
@@ -43,16 +79,20 @@ namespace boost
threads.push_back(new_thread.get());
return new_thread.release();
}
-
+
void add_thread(thread* thrd)
{
if(thrd)
{
+ BOOST_THREAD_ASSERT_PRECONDITION( ! is_thread_in(thrd) ,
+ thread_resource_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost::thread_group: trying to add a duplicated thread")
+ );
+
boost::lock_guard<shared_mutex> guard(m);
threads.push_back(thrd);
}
}
-
+
void remove_thread(thread* thrd)
{
boost::lock_guard<shared_mutex> guard(m);
@@ -62,23 +102,28 @@ namespace boost
threads.erase(it);
}
}
-
+
void join_all()
{
+ BOOST_THREAD_ASSERT_PRECONDITION( ! is_this_thread_in() ,
+ thread_resource_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost::thread_group: trying joining itself")
+ );
boost::shared_lock<shared_mutex> guard(m);
-
+
for(std::list<thread*>::iterator it=threads.begin(),end=threads.end();
it!=end;
++it)
{
+ if ((*it)->joinable())
(*it)->join();
}
}
-
+
+#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
void interrupt_all()
{
boost::shared_lock<shared_mutex> guard(m);
-
+
for(std::list<thread*>::iterator it=threads.begin(),end=threads.end();
it!=end;
++it)
@@ -86,13 +131,14 @@ namespace boost
(*it)->interrupt();
}
}
-
+#endif
+
size_t size() const
{
boost::shared_lock<shared_mutex> guard(m);
return threads.size();
}
-
+
private:
std::list<thread*> threads;
mutable shared_mutex m;