From 3fe885d0358193bd81414bcfc0c6574488732137 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Sat, 24 Nov 2012 10:56:05 +0100 Subject: [PATCH] remove dependency to boost.thread - use __thread/__declspec(thread) for static thread-local pointer to scheduler --- boost/fiber/detail/scheduler.hpp | 1 - libs/fiber/build/Jamfile.v2 | 1 - libs/fiber/examples/Jamfile.v2 | 1 - libs/fiber/src/detail/scheduler.cpp | 12 ++++++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/boost/fiber/detail/scheduler.hpp b/boost/fiber/detail/scheduler.hpp index 12c025d1..42731eca 100644 --- a/boost/fiber/detail/scheduler.hpp +++ b/boost/fiber/detail/scheduler.hpp @@ -76,7 +76,6 @@ private: > wqueue_t; typedef wqueue_t::index< f_tag_t >::type f_idx_t; typedef wqueue_t::index< tp_tag_t >::type tp_idx_t; - typedef std::deque< fiber_base::ptr_t > rqueue_t; fiber_base::ptr_t active_fiber_; diff --git a/libs/fiber/build/Jamfile.v2 b/libs/fiber/build/Jamfile.v2 index 3ec90514..007e91d8 100644 --- a/libs/fiber/build/Jamfile.v2 +++ b/libs/fiber/build/Jamfile.v2 @@ -13,7 +13,6 @@ project boost/fiber : requirements /boost/chrono//boost_chrono /boost/context//boost_context - /boost/thread//boost_thread static multi : source-location ../src diff --git a/libs/fiber/examples/Jamfile.v2 b/libs/fiber/examples/Jamfile.v2 index 9b913a0e..a5d61fa0 100644 --- a/libs/fiber/examples/Jamfile.v2 +++ b/libs/fiber/examples/Jamfile.v2 @@ -12,7 +12,6 @@ project boost/fiber/example ../build//boost_fibers /boost/context//boost_context /boost/system//boost_system - /boost/thread//boost_thread static multi ; diff --git a/libs/fiber/src/detail/scheduler.cpp b/libs/fiber/src/detail/scheduler.cpp index c2f5420b..add8d71d 100644 --- a/libs/fiber/src/detail/scheduler.cpp +++ b/libs/fiber/src/detail/scheduler.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include @@ -46,9 +45,14 @@ scheduler::~scheduler() scheduler & scheduler::instance() { - static thread_specific_ptr< scheduler > static_local; - if ( ! static_local.get() ) static_local.reset( new scheduler() ); - return * static_local.get(); +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__) || \ + (defined(__ICC) && defined(BOOST_WINDOWS)) + static __declspec(thread) scheduler * static_local = 0; +#else + static __thread scheduler * static_local = 0; +#endif + if ( ! static_local) static_local = new scheduler(); + return * static_local; } void