summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/thread/win32/thread_data.hpp')
-rw-r--r--3rdParty/Boost/src/boost/thread/win32/thread_data.hpp127
1 files changed, 102 insertions, 25 deletions
diff --git a/3rdParty/Boost/src/boost/thread/win32/thread_data.hpp b/3rdParty/Boost/src/boost/thread/win32/thread_data.hpp
index c86b0fa..18fd7cb 100644
--- a/3rdParty/Boost/src/boost/thread/win32/thread_data.hpp
+++ b/3rdParty/Boost/src/boost/thread/win32/thread_data.hpp
@@ -4,51 +4,116 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// (C) Copyright 2008 Anthony Williams
+// (C) Copyright 2011-2012 Vicente J. Botet Escriba
#include <boost/thread/detail/config.hpp>
-#include <boost/intrusive_ptr.hpp>
#include <boost/thread/thread_time.hpp>
-#include "thread_primitives.hpp"
-#include "thread_heap_alloc.hpp"
+#include <boost/thread/win32/thread_primitives.hpp>
+#include <boost/thread/win32/thread_heap_alloc.hpp>
+
+#include <boost/intrusive_ptr.hpp>
+#ifdef BOOST_THREAD_USES_CHRONO
+#include <boost/chrono/system_clocks.hpp>
+#endif
+
+#include <map>
+#include <vector>
+#include <utility>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
+ class condition_variable;
+ class mutex;
+
+ class thread_attributes {
+ public:
+ thread_attributes() BOOST_NOEXCEPT {
+ val_.stack_size = 0;
+ //val_.lpThreadAttributes=0;
+ }
+ ~thread_attributes() {
+ }
+ // stack size
+ void set_stack_size(std::size_t size) BOOST_NOEXCEPT {
+ val_.stack_size = size;
+ }
+
+ std::size_t get_stack_size() const BOOST_NOEXCEPT {
+ return val_.stack_size;
+ }
+
+ //void set_security(LPSECURITY_ATTRIBUTES lpThreadAttributes)
+ //{
+ // val_.lpThreadAttributes=lpThreadAttributes;
+ //}
+ //LPSECURITY_ATTRIBUTES get_security()
+ //{
+ // return val_.lpThreadAttributes;
+ //}
+
+ struct win_attrs {
+ std::size_t stack_size;
+ //LPSECURITY_ATTRIBUTES lpThreadAttributes;
+ };
+ typedef win_attrs native_handle_type;
+ native_handle_type* native_handle() {return &val_;}
+ const native_handle_type* native_handle() const {return &val_;}
+
+ private:
+ win_attrs val_;
+ };
+
namespace detail
{
+ struct tss_cleanup_function;
struct thread_exit_callback_node;
- struct tss_data_node;
+ struct tss_data_node
+ {
+ boost::shared_ptr<boost::detail::tss_cleanup_function> func;
+ void* value;
+
+ tss_data_node(boost::shared_ptr<boost::detail::tss_cleanup_function> func_,
+ void* value_):
+ func(func_),value(value_)
+ {}
+ };
struct thread_data_base;
void intrusive_ptr_add_ref(thread_data_base * p);
void intrusive_ptr_release(thread_data_base * p);
-
- struct thread_data_base
+
+ struct BOOST_THREAD_DECL thread_data_base
{
long count;
detail::win32::handle_manager thread_handle;
detail::win32::handle_manager interruption_handle;
boost::detail::thread_exit_callback_node* thread_exit_callbacks;
- boost::detail::tss_data_node* tss_data;
+ std::map<void const*,boost::detail::tss_data_node> tss_data;
bool interruption_enabled;
unsigned id;
+ typedef std::vector<std::pair<condition_variable*, mutex*>
+ //, hidden_allocator<std::pair<condition_variable*, mutex*> >
+ > notify_list_t;
+ notify_list_t notify;
+
thread_data_base():
count(0),thread_handle(detail::win32::invalid_handle_value),
interruption_handle(create_anonymous_event(detail::win32::manual_reset_event,detail::win32::event_initially_reset)),
- thread_exit_callbacks(0),tss_data(0),
+ thread_exit_callbacks(0),tss_data(),
interruption_enabled(true),
- id(0)
- {}
- virtual ~thread_data_base()
+ id(0),
+ notify()
{}
+ virtual ~thread_data_base();
friend void intrusive_ptr_add_ref(thread_data_base * p)
{
BOOST_INTERLOCKED_INCREMENT(&p->count);
}
-
+
friend void intrusive_ptr_release(thread_data_base * p)
{
if(!BOOST_INTERLOCKED_DECREMENT(&p->count))
@@ -61,15 +126,21 @@ namespace boost
{
BOOST_VERIFY(detail::win32::SetEvent(interruption_handle)!=0);
}
-
+
typedef detail::win32::handle native_handle_type;
virtual void run()=0;
+
+ void notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+ {
+ notify.push_back(std::pair<condition_variable*, mutex*>(cv, m));
+ }
+
};
typedef boost::intrusive_ptr<detail::thread_data_base> thread_data_ptr;
- struct timeout
+ struct BOOST_SYMBOL_VISIBLE timeout
{
unsigned long start;
uintmax_t milliseconds;
@@ -92,7 +163,7 @@ namespace boost
abs_time(abs_time_)
{}
- struct remaining_time
+ struct BOOST_SYMBOL_VISIBLE remaining_time
{
bool more;
unsigned long milliseconds;
@@ -130,7 +201,7 @@ namespace boost
{
return milliseconds==~uintmax_t(0);
}
-
+
static timeout sentinel()
{
@@ -139,43 +210,49 @@ namespace boost
private:
struct sentinel_type
{};
-
+
explicit timeout(sentinel_type):
start(0),milliseconds(~uintmax_t(0)),relative(true)
{}
};
- inline unsigned long pin_to_zero(long value)
+ inline uintmax_t pin_to_zero(intmax_t value)
{
- return (value<0)?0u:(unsigned long)value;
+ return (value<0)?0u:(uintmax_t)value;
}
}
namespace this_thread
{
- void BOOST_THREAD_DECL yield();
+ void BOOST_THREAD_DECL yield() BOOST_NOEXCEPT;
bool BOOST_THREAD_DECL interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time);
- inline void interruptible_wait(unsigned long milliseconds)
+ inline void interruptible_wait(uintmax_t milliseconds)
{
interruptible_wait(detail::win32::invalid_handle_value,milliseconds);
}
- inline void interruptible_wait(system_time const& abs_time)
+ inline BOOST_SYMBOL_VISIBLE void interruptible_wait(system_time const& abs_time)
{
interruptible_wait(detail::win32::invalid_handle_value,abs_time);
}
template<typename TimeDuration>
- inline void sleep(TimeDuration const& rel_time)
+ inline BOOST_SYMBOL_VISIBLE void sleep(TimeDuration const& rel_time)
{
interruptible_wait(detail::pin_to_zero(rel_time.total_milliseconds()));
}
- inline void sleep(system_time const& abs_time)
+ inline BOOST_SYMBOL_VISIBLE void sleep(system_time const& abs_time)
{
interruptible_wait(abs_time);
}
+#ifdef BOOST_THREAD_USES_CHRONO
+ inline void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns)
+ {
+ interruptible_wait(chrono::duration_cast<chrono::milliseconds>(ns).count());
+ }
+#endif
}
-
+
}
#include <boost/config/abi_suffix.hpp>