Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57676 - in sandbox/fiber: boost/fiber/detail libs/fiber/build libs/fiber/src
From: oliver.kowalke_at_[hidden]
Date: 2009-11-15 03:54:35


Author: olli
Date: 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
New Revision: 57676
URL: http://svn.boost.org/trac/boost/changeset/57676

Log:
- refactoring relates fiber_info_base and Win32/POSIX

Added:
   sandbox/fiber/boost/fiber/detail/fiber_info_base.hpp (contents, props changed)
   sandbox/fiber/boost/fiber/detail/fiber_info_base_posix.hpp (contents, props changed)
   sandbox/fiber/boost/fiber/detail/fiber_info_base_windows.hpp (contents, props changed)
   sandbox/fiber/libs/fiber/src/fiber_info_base_posix.cpp (contents, props changed)
   sandbox/fiber/libs/fiber/src/fiber_info_base_windows.cpp (contents, props changed)
Removed:
   sandbox/fiber/boost/fiber/detail/fiber_info_posix.hpp
   sandbox/fiber/boost/fiber/detail/fiber_info_windows.hpp
   sandbox/fiber/libs/fiber/src/fiber_info_posix.cpp
   sandbox/fiber/libs/fiber/src/fiber_info_windows.cpp
Text files modified:
   sandbox/fiber/boost/fiber/detail/fiber_info.hpp | 9 +--------
   sandbox/fiber/libs/fiber/build/Jamfile.v2 | 4 ++--
   sandbox/fiber/libs/fiber/src/scheduler_impl.cpp | 3 +++
   3 files changed, 6 insertions(+), 10 deletions(-)

Modified: sandbox/fiber/boost/fiber/detail/fiber_info.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/fiber_info.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/fiber_info.hpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -13,16 +13,9 @@
 
 #include <boost/fiber/attributes.hpp>
 #include <boost/fiber/detail/config.hpp>
+#include <boost/fiber/detail/fiber_info_base.hpp>
 #include <boost/fiber/detail/move.hpp>
 
-# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-#include <boost/fiber/detail/fiber_info_windows.hpp>
-
-# elif defined(_POSIX_VERSION)
-#include <boost/fiber/detail/fiber_info_posix.hpp>
-
-# endif
-
 #include <boost/config/abi_prefix.hpp>
 
 namespace boost {

Added: sandbox/fiber/boost/fiber/detail/fiber_info_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/fiber/boost/fiber/detail/fiber_info_base.hpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,18 @@
+
+// Copyright Oliver Kowalke 2009.
+// 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)
+
+#ifndef BOOST_FIBER_DETAIL_FIBER_INFO_BASE_H
+#define BOOST_FIBER_DETAIL_FIBER_INFO_BASE_H
+
+#include <boost/fiber/detail/config.hpp>
+
+# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#include <boost/fiber/detail/fiber_info_base_windows.hpp>
+# elif defined(_POSIX_VERSION)
+#include <boost/fiber/detail/fiber_info_base_posix.hpp>
+# endif
+
+#endif // BOOST_FIBER_DETAIL_FIBER_INFO_BASE_H

Added: sandbox/fiber/boost/fiber/detail/fiber_info_base_posix.hpp
==============================================================================
--- (empty file)
+++ sandbox/fiber/boost/fiber/detail/fiber_info_base_posix.hpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,63 @@
+
+// Copyright Oliver Kowalke 2009.
+// 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)
+
+#ifndef BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H
+#define BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H
+
+extern "C" {
+
+#include <ucontext.h>
+
+}
+
+#include <boost/cstdint.hpp>
+#include <boost/intrusive_ptr.hpp>
+#include <boost/shared_array.hpp>
+
+#include <boost/fiber/attributes.hpp>
+#include <boost/fiber/detail/config.hpp>
+#include <boost/fiber/detail/fiber_state.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost {
+namespace fibers {
+namespace detail {
+
+struct BOOST_FIBER_DECL fiber_info_base
+{
+ typedef intrusive_ptr< fiber_info_base > ptr_t;
+
+ uint32_t use_count;
+ attributes attrs;
+ ::ucontext_t uctx;
+ shared_array< char > uctx_stack;
+ fiber_state_t state;
+
+ static void convert_thread_to_fiber() {}
+
+ fiber_info_base();
+
+ fiber_info_base( attributes const&);
+
+ virtual ~fiber_info_base() {}
+
+ virtual void run() = 0;
+
+ inline friend void intrusive_ptr_add_ref( fiber_info_base * p)
+ { ++p->use_count; }
+
+ inline friend void intrusive_ptr_release( fiber_info_base * p)
+ { if ( --p->use_count == 0) delete p; }
+};
+
+}}
+
+}
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H

Added: sandbox/fiber/boost/fiber/detail/fiber_info_base_windows.hpp
==============================================================================
--- (empty file)
+++ sandbox/fiber/boost/fiber/detail/fiber_info_base_windows.hpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,86 @@
+
+// Copyright Oliver Kowalke 2009.
+// 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)
+
+#ifndef BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H
+#define BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H
+
+extern "C" {
+
+#include <windows.h>
+#include <winnt.h>
+
+}
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/intrusive_ptr.hpp>
+#include <boost/shared_array.hpp>
+
+#include <boost/fiber/attributes.hpp>
+#include <boost/fiber/detail/config.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost {
+namespace fibers {
+namespace detail {
+
+struct BOOST_FIBER_DECL fiber_info_base
+{
+ typedef intrusive_ptr< fiber_info_base > ptr_t;
+
+ uint32_t use_count;
+ attributes attribs;
+ LPVOID uctx;
+
+ static void convert_thread_to_fiber() {}
+
+ fiber_info_base();
+
+ fiber_info_base( attributes const&);
+
+ virtual ~fiber_info_base() {}
+
+ virtual void run() = 0;
+
+#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+
+ inline friend void intrusive_ptr_add_ref( fiber_info_base * p)
+ { ++p->use_count; }
+
+ inline friend void intrusive_ptr_release( fiber_info_base * p)
+ { if ( --p->use_count == 0) delete p; }
+
+#else
+
+ void add_ref()
+ { ++use_count; }
+
+ void release()
+ { if ( --use_count == 0) delete this; }
+
+#endif
+};
+
+}}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+
+inline
+void intrusive_ptr_add_ref( fiber::detail::fiber_info_base * p)
+{ p->add_ref(); }
+
+inline
+void intrusive_ptr_release( fiber::detail::fiber_info_base * p)
+{ p->release(); }
+
+#endif
+
+}
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H

Deleted: sandbox/fiber/boost/fiber/detail/fiber_info_posix.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/fiber_info_posix.hpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
+++ (empty file)
@@ -1,63 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// 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)
-
-#ifndef BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H
-#define BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H
-
-extern "C" {
-
-#include <ucontext.h>
-
-}
-
-#include <boost/cstdint.hpp>
-#include <boost/intrusive_ptr.hpp>
-#include <boost/shared_array.hpp>
-
-#include <boost/fiber/attributes.hpp>
-#include <boost/fiber/detail/config.hpp>
-#include <boost/fiber/detail/fiber_state.hpp>
-
-#include <boost/config/abi_prefix.hpp>
-
-namespace boost {
-namespace fibers {
-namespace detail {
-
-struct BOOST_FIBER_DECL fiber_info_base
-{
- typedef intrusive_ptr< fiber_info_base > ptr_t;
-
- uint32_t use_count;
- attributes attrs;
- ::ucontext_t uctx;
- shared_array< char > uctx_stack;
- fiber_state_t state;
-
- static void convert_thread_to_fiber() {}
-
- fiber_info_base();
-
- fiber_info_base( attributes const&);
-
- virtual ~fiber_info_base() {}
-
- virtual void run() = 0;
-
- inline friend void intrusive_ptr_add_ref( fiber_info_base * p)
- { ++p->use_count; }
-
- inline friend void intrusive_ptr_release( fiber_info_base * p)
- { if ( --p->use_count == 0) delete p; }
-};
-
-}}
-
-}
-
-#include <boost/config/abi_suffix.hpp>
-
-#endif // BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H

Deleted: sandbox/fiber/boost/fiber/detail/fiber_info_windows.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/fiber_info_windows.hpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
+++ (empty file)
@@ -1,86 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// 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)
-
-#ifndef BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H
-#define BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H
-
-extern "C" {
-
-#include <windows.h>
-#include <winnt.h>
-
-}
-
-#include <boost/config.hpp>
-#include <boost/cstdint.hpp>
-#include <boost/intrusive_ptr.hpp>
-#include <boost/shared_array.hpp>
-
-#include <boost/fiber/attributes.hpp>
-#include <boost/fiber/detail/config.hpp>
-
-#include <boost/config/abi_prefix.hpp>
-
-namespace boost {
-namespace fibers {
-namespace detail {
-
-struct BOOST_FIBER_DECL fiber_info_base
-{
- typedef intrusive_ptr< fiber_info_base > ptr_t;
-
- uint32_t use_count;
- attributes attribs;
- LPVOID uctx;
-
- static void convert_thread_to_fiber() {}
-
- fiber_info_base();
-
- fiber_info_base( attributes const&);
-
- virtual ~fiber_info_base() {}
-
- virtual void run() = 0;
-
-#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
-
- inline friend void intrusive_ptr_add_ref( fiber_info_base * p)
- { ++p->use_count; }
-
- inline friend void intrusive_ptr_release( fiber_info_base * p)
- { if ( --p->use_count == 0) delete p; }
-
-#else
-
- void add_ref()
- { ++use_count; }
-
- void release()
- { if ( --use_count == 0) delete this; }
-
-#endif
-};
-
-}}
-
-#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
-
-inline
-void intrusive_ptr_add_ref( fiber::detail::fiber_info_base * p)
-{ p->add_ref(); }
-
-inline
-void intrusive_ptr_release( fiber::detail::fiber_info_base * p)
-{ p->release(); }
-
-#endif
-
-}
-
-#include <boost/config/abi_suffix.hpp>
-
-#endif // BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H

Modified: sandbox/fiber/libs/fiber/build/Jamfile.v2
==============================================================================
--- sandbox/fiber/libs/fiber/build/Jamfile.v2 (original)
+++ sandbox/fiber/libs/fiber/build/Jamfile.v2 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -40,7 +40,7 @@
         condition.cpp
         count_down_event.cpp
         fiber.cpp
- fiber_info_windows.cpp
+ fiber_info_base_windows.cpp
         fiber_windows.cpp
         manual_reset_event.cpp
         mutex.cpp
@@ -57,7 +57,7 @@
         condition.cpp
         count_down_event.cpp
         fiber.cpp
- fiber_info_posix.cpp
+ fiber_info_base_posix.cpp
         fiber_posix.cpp
         manual_reset_event.cpp
         mutex.cpp

Added: sandbox/fiber/libs/fiber/src/fiber_info_base_posix.cpp
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/src/fiber_info_base_posix.cpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,47 @@
+
+// Copyright Oliver Kowalke 2009.
+// 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/fiber/detail/fiber_info_base_posix.hpp>
+
+#include <cerrno>
+
+#include <boost/assert.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost {
+namespace fibers {
+namespace detail {
+
+fiber_info_base::fiber_info_base() :
+ attrs(),
+ uctx(),
+ uctx_stack(),
+ state( STATE_MASTER)
+{}
+
+fiber_info_base::fiber_info_base( attributes const& attrs_) :
+ attrs( attrs_),
+ uctx(),
+ uctx_stack( new char[attrs.stack_size()]),
+ state( STATE_NOT_STARTED)
+{
+ BOOST_ASSERT( uctx_stack);
+
+ if ( ::getcontext( & uctx) == -1)
+ throw system::system_error(
+ system::error_code(
+ errno,
+ system::system_category) );
+ uctx.uc_stack.ss_sp = uctx_stack.get();
+ uctx.uc_stack.ss_size = attrs.stack_size();
+ uctx.uc_link = 0;
+}
+
+}}}
+
+#include <boost/config/abi_suffix.hpp>

Added: sandbox/fiber/libs/fiber/src/fiber_info_base_windows.cpp
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/src/fiber_info_base_windows.cpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,45 @@
+
+// Copyright Oliver Kowalke 2009.
+// 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/fiber/detail/fiber_info_base_posix.hpp>
+
+#include <cerrno>
+
+#include <boost/assert.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost {
+namespace fibers {
+namespace detail {
+
+fiber_info_base::fiber_info_base() :
+ attribs(),
+ uctx(),
+ uctx_stack()
+{}
+
+fiber_info_base::fiber_info_base( attributes const& attribs_) :
+ attribs( attribs_),
+ uctx(),
+ uctx_stack( new char[attribs.stack_size()])
+{
+ BOOST_ASSERT( uctx_stack);
+
+ if ( ::getcontext( & uctx) == -1)
+ throw system::system_error(
+ system::error_code(
+ errno,
+ system::system_category) );
+ uctx.uc_stack.ss_sp = uctx_stack.get();
+ uctx.uc_stack.ss_size = attribs.stack_size();
+ uctx.uc_link = 0;
+}
+
+}}}
+
+#include <boost/config/abi_suffix.hpp>

Deleted: sandbox/fiber/libs/fiber/src/fiber_info_posix.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber_info_posix.cpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
+++ (empty file)
@@ -1,47 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// 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/fiber/detail/fiber_info_posix.hpp>
-
-#include <cerrno>
-
-#include <boost/assert.hpp>
-#include <boost/system/system_error.hpp>
-
-#include <boost/config/abi_prefix.hpp>
-
-namespace boost {
-namespace fibers {
-namespace detail {
-
-fiber_info_base::fiber_info_base() :
- attrs(),
- uctx(),
- uctx_stack(),
- state( STATE_MASTER)
-{}
-
-fiber_info_base::fiber_info_base( attributes const& attrs_) :
- attrs( attrs_),
- uctx(),
- uctx_stack( new char[attrs.stack_size()]),
- state( STATE_NOT_STARTED)
-{
- BOOST_ASSERT( uctx_stack);
-
- if ( ::getcontext( & uctx) == -1)
- throw system::system_error(
- system::error_code(
- errno,
- system::system_category) );
- uctx.uc_stack.ss_sp = uctx_stack.get();
- uctx.uc_stack.ss_size = attrs.stack_size();
- uctx.uc_link = 0;
-}
-
-}}}
-
-#include <boost/config/abi_suffix.hpp>

Deleted: sandbox/fiber/libs/fiber/src/fiber_info_windows.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber_info_windows.cpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
+++ (empty file)
@@ -1,45 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// 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/fiber/detail/fiber_info_posix.hpp>
-
-#include <cerrno>
-
-#include <boost/assert.hpp>
-#include <boost/system/system_error.hpp>
-
-#include <boost/config/abi_prefix.hpp>
-
-namespace boost {
-namespace fibers {
-namespace detail {
-
-fiber_info_base::fiber_info_base() :
- attribs(),
- uctx(),
- uctx_stack()
-{}
-
-fiber_info_base::fiber_info_base( attributes const& attribs_) :
- attribs( attribs_),
- uctx(),
- uctx_stack( new char[attribs.stack_size()])
-{
- BOOST_ASSERT( uctx_stack);
-
- if ( ::getcontext( & uctx) == -1)
- throw system::system_error(
- system::error_code(
- errno,
- system::system_category) );
- uctx.uc_stack.ss_sp = uctx_stack.get();
- uctx.uc_stack.ss_size = attribs.stack_size();
- uctx.uc_link = 0;
-}
-
-}}}
-
-#include <boost/config/abi_suffix.hpp>

Modified: sandbox/fiber/libs/fiber/src/scheduler_impl.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/scheduler_impl.cpp (original)
+++ sandbox/fiber/libs/fiber/src/scheduler_impl.cpp 2009-11-15 03:54:34 EST (Sun, 15 Nov 2009)
@@ -292,6 +292,9 @@
                 runnable_fibers_.pop_front();
                 result = true;
         }
+ else
+ boost::move( active_);
+
         while ( ! terminated_fibers_.empty() )
         {
                 fiber f( fibers_[terminated_fibers_.front()].f);


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