|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75787 - in trunk: boost/thread/pthread libs/thread/src/pthread
From: vicente.botet_at_[hidden]
Date: 2011-12-03 08:57:07
Author: viboes
Date: 2011-12-03 08:57:06 EST (Sat, 03 Dec 2011)
New Revision: 75787
URL: http://svn.boost.org/trac/boost/changeset/75787
Log:
Thread: 4480 OpenVMS patches for compiler issues workarounds (only sleep part)
Text files modified:
trunk/boost/thread/pthread/thread_data.hpp | 24 ++++++++++++++----
trunk/libs/thread/src/pthread/thread.cpp | 50 +++++++++++++++++++++------------------
2 files changed, 45 insertions(+), 29 deletions(-)
Modified: trunk/boost/thread/pthread/thread_data.hpp
==============================================================================
--- trunk/boost/thread/pthread/thread_data.hpp (original)
+++ trunk/boost/thread/pthread/thread_data.hpp 2011-12-03 08:57:06 EST (Sat, 03 Dec 2011)
@@ -13,7 +13,7 @@
#include <boost/optional.hpp>
#include <pthread.h>
#include <boost/assert.hpp>
-#include "condition_variable_fwd.hpp"
+#include <boost/thread/pthread/condition_variable_fwd.hpp>
#include <map>
#include <boost/config/abi_prefix.hpp>
@@ -21,7 +21,7 @@
namespace boost
{
class thread;
-
+
namespace detail
{
struct tss_cleanup_function;
@@ -39,7 +39,7 @@
struct thread_data_base;
typedef boost::shared_ptr<thread_data_base> thread_data_ptr;
-
+
struct BOOST_THREAD_DECL thread_data_base:
enable_shared_from_this<thread_data_base>
{
@@ -89,7 +89,7 @@
throw thread_interrupted();
}
}
-
+
void operator=(interruption_checker&);
public:
explicit interruption_checker(pthread_mutex_t* cond_mutex,pthread_cond_t* cond):
@@ -129,14 +129,26 @@
namespace this_thread
{
void BOOST_THREAD_DECL yield();
-
+
+#ifdef __DECXXX
+ /// Workaround of DECCXX issue of incorrect template substitution
+ template<typename TimeDuration>
+ inline void sleep(TimeDuration const& rel_time)
+ {
+ this_thread::sleep(get_system_time()+rel_time);
+ }
+
+ template<>
void BOOST_THREAD_DECL sleep(system_time const& abs_time);
-
+#else
+ void BOOST_THREAD_DECL sleep(system_time const& abs_time);
+
template<typename TimeDuration>
inline void sleep(TimeDuration const& rel_time)
{
this_thread::sleep(get_system_time()+rel_time);
}
+#endif
}
}
Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2011-12-03 08:57:06 EST (Sat, 03 Dec 2011)
@@ -2,7 +2,7 @@
// William E. Kempf
// Copyright (C) 2007-8 Anthony Williams
//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/detail/config.hpp>
@@ -86,14 +86,14 @@
}
}
}
-
+
void create_current_thread_tls_key()
{
BOOST_VERIFY(!pthread_key_create(¤t_thread_tls_key,&tls_destructor));
}
}
-
+
boost::detail::thread_data_base* get_current_thread_data()
{
boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
@@ -106,7 +106,7 @@
BOOST_VERIFY(!pthread_setspecific(current_thread_tls_key,new_data));
}
}
-
+
namespace
{
extern "C"
@@ -146,7 +146,7 @@
{
interrupt_enabled=false;
}
-
+
void run()
{}
@@ -207,7 +207,7 @@
if(local_thread_info)
{
bool do_join=false;
-
+
{
unique_lock<mutex> lock(local_thread_info->data_mutex);
while(!local_thread_info->done)
@@ -215,7 +215,7 @@
local_thread_info->done_condition.wait(lock);
}
do_join=!local_thread_info->join_started;
-
+
if(do_join)
{
local_thread_info->join_started=true;
@@ -236,7 +236,7 @@
local_thread_info->joined=true;
local_thread_info->done_condition.notify_all();
}
-
+
if(thread_info==local_thread_info)
{
thread_info.reset();
@@ -250,7 +250,7 @@
if(local_thread_info)
{
bool do_join=false;
-
+
{
unique_lock<mutex> lock(local_thread_info->data_mutex);
while(!local_thread_info->done)
@@ -261,7 +261,7 @@
}
}
do_join=!local_thread_info->join_started;
-
+
if(do_join)
{
local_thread_info->join_started=true;
@@ -282,7 +282,7 @@
local_thread_info->joined=true;
local_thread_info->done_condition.notify_all();
}
-
+
if(thread_info==local_thread_info)
{
thread_info.reset();
@@ -301,7 +301,7 @@
{
detail::thread_data_ptr local_thread_info;
thread_info.swap(local_thread_info);
-
+
if(local_thread_info)
{
lock_guard<mutex> lock(local_thread_info->data_mutex);
@@ -316,11 +316,15 @@
namespace this_thread
{
-
+
+#ifdef __DECXXX
+ /// Workaround of DECCXX issue of incorrect template substitution
+ template<>
+#endif
void sleep(const system_time& st)
{
detail::thread_data_base* const thread_info=detail::get_current_thread_data();
-
+
if(thread_info)
{
unique_lock<mutex> lk(thread_info->sleep_mutex);
@@ -329,7 +333,7 @@
else
{
xtime const xt=get_xtime(st);
-
+
for (int foo=0; foo < 5; ++foo)
{
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
@@ -339,7 +343,7 @@
# elif defined(BOOST_HAS_NANOSLEEP)
timespec ts;
to_timespec_duration(xt, ts);
-
+
// nanosleep takes a timespec that is an offset, not
// an absolute time.
nanosleep(&ts, 0);
@@ -444,8 +448,8 @@
return pthread_t();
}
}
-
-
+
+
namespace this_thread
{
@@ -468,13 +472,13 @@
}
}
}
-
+
bool interruption_enabled()
{
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
return thread_info && thread_info->interrupt_enabled;
}
-
+
bool interruption_requested()
{
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
@@ -497,7 +501,7 @@
detail::get_current_thread_data()->interrupt_enabled=false;
}
}
-
+
disable_interruption::~disable_interruption()
{
if(detail::get_current_thread_data())
@@ -513,7 +517,7 @@
detail::get_current_thread_data()->interrupt_enabled=true;
}
}
-
+
restore_interruption::~restore_interruption()
{
if(detail::get_current_thread_data())
@@ -570,7 +574,7 @@
detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
current_thread_data->tss_data.erase(key);
}
-
+
void set_tss_data(void const* key,
boost::shared_ptr<tss_cleanup_function> func,
void* tss_data,bool cleanup_existing)
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