|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58013 - in sandbox/fiber: boost/fiber/detail libs/fiber/src
From: oliver.kowalke_at_[hidden]
Date: 2009-11-28 14:29:33
Author: olli
Date: 2009-11-28 14:29:33 EST (Sat, 28 Nov 2009)
New Revision: 58013
URL: http://svn.boost.org/trac/boost/changeset/58013
Log:
- corrections related to Windows
-> is_thread_a_fiber() added
-> test in ConvertThreadToFiber() and ConvertFiberToThread()
Text files modified:
sandbox/fiber/boost/fiber/detail/fiber_info_base_windows.hpp | 4 ++++
sandbox/fiber/libs/fiber/src/fiber_info_base_windows.cpp | 3 ++-
sandbox/fiber/libs/fiber/src/fiber_windows.cpp | 36 ++++++++++++++++++++++++++----------
sandbox/fiber/libs/fiber/src/strategy.cpp | 2 +-
4 files changed, 33 insertions(+), 12 deletions(-)
Modified: sandbox/fiber/boost/fiber/detail/fiber_info_base_windows.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/fiber_info_base_windows.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/fiber_info_base_windows.hpp 2009-11-28 14:29:33 EST (Sat, 28 Nov 2009)
@@ -32,6 +32,9 @@
namespace boost {
namespace fibers {
+
+class strategy;
+
namespace detail {
struct BOOST_FIBER_DECL fiber_info_base
@@ -47,6 +50,7 @@
fiber_state_t state;
fiber_interrupt_t interrupt;
callable_stack_t at_exit;
+ strategy * st;
fiber_info_base();
Modified: sandbox/fiber/libs/fiber/src/fiber_info_base_windows.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber_info_base_windows.cpp (original)
+++ sandbox/fiber/libs/fiber/src/fiber_info_base_windows.cpp 2009-11-28 14:29:33 EST (Sat, 28 Nov 2009)
@@ -24,7 +24,8 @@
uctx(),
state( STATE_MASTER),
interrupt( INTERRUPTION_DISABLED),
- at_exit()
+ at_exit(),
+ st( 0)
{
uctx = ::GetCurrentFiber();
if ( ! uctx)
Modified: sandbox/fiber/libs/fiber/src/fiber_windows.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber_windows.cpp (original)
+++ sandbox/fiber/libs/fiber/src/fiber_windows.cpp 2009-11-28 14:29:33 EST (Sat, 28 Nov 2009)
@@ -21,6 +21,20 @@
#include <boost/config/abi_prefix.hpp>
+namespace {
+
+bool is_thread_a_fiber()
+{
+#if ( _WIN32_WINNT > 0x0600)
+ return ::IsThreadAFiber() == TRUE;
+#else
+ LPVOID current = ::GetCurrentFiber();
+ return 0 != current && current != reinterpret_cast< LPVOID >( 0x1E00);
+#endif
+}
+
+}
+
namespace boost {
namespace fibers {
@@ -65,21 +79,23 @@
void
fiber::convert_thread_to_fiber()
{
- if ( ::ConvertThreadToFiber( 0) == 0)
- throw system::system_error(
- system::error_code(
- GetLastError(),
- system::system_category) );
+ if ( ! is_thread_a_fiber() )
+ if ( ::ConvertThreadToFiber( 0) == 0)
+ throw system::system_error(
+ system::error_code(
+ GetLastError(),
+ system::system_category) );
}
void
fiber::convert_fiber_to_thread()
{
- if ( ::ConvertFiberToThread() == 0)
- throw system::system_error(
- system::error_code(
- GetLastError(),
- system::system_category) );
+ if ( ! this_fiber::runs_as_fiber() && is_thread_a_fiber() )
+ if ( ::ConvertFiberToThread() == 0)
+ throw system::system_error(
+ system::error_code(
+ GetLastError(),
+ system::system_category) );
}
}}
Modified: sandbox/fiber/libs/fiber/src/strategy.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/strategy.cpp (original)
+++ sandbox/fiber/libs/fiber/src/strategy.cpp 2009-11-28 14:29:33 EST (Sat, 28 Nov 2009)
@@ -53,7 +53,7 @@
{
fiber * active( active_fiber.get() );
if ( ! active) throw fiber_error("not a fiber");
- return active->info_()->interrupt & detail::INTERRUPTION_ENABLED;
+ return ( active->info_()->interrupt & detail::INTERRUPTION_ENABLED) != 0;
}
int
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