Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58016 - in sandbox/fiber: boost/fiber libs/fiber/doc libs/fiber/src
From: oliver.kowalke_at_[hidden]
Date: 2009-11-28 15:38:09


Author: olli
Date: 2009-11-28 15:38:08 EST (Sat, 28 Nov 2009)
New Revision: 58016
URL: http://svn.boost.org/trac/boost/changeset/58016

Log:
- add detach() to strategy
- detach all remaining fibers in the destructor of round_robin

Text files modified:
   sandbox/fiber/boost/fiber/round_robin.hpp | 2 ++
   sandbox/fiber/boost/fiber/strategy.hpp | 2 ++
   sandbox/fiber/libs/fiber/doc/fiber_ref.qbk | 13 +++++++++++++
   sandbox/fiber/libs/fiber/src/round_robin.cpp | 6 ++++++
   sandbox/fiber/libs/fiber/src/strategy.cpp | 6 ++++++
   5 files changed, 29 insertions(+), 0 deletions(-)

Modified: sandbox/fiber/boost/fiber/round_robin.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/round_robin.hpp (original)
+++ sandbox/fiber/boost/fiber/round_robin.hpp 2009-11-28 15:38:08 EST (Sat, 28 Nov 2009)
@@ -61,6 +61,8 @@
 public:
         round_robin();
 
+ ~round_robin();
+
         void add( fiber);
 
         void yield( fiber::id const&);

Modified: sandbox/fiber/boost/fiber/strategy.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/strategy.hpp (original)
+++ sandbox/fiber/boost/fiber/strategy.hpp 2009-11-28 15:38:08 EST (Sat, 28 Nov 2009)
@@ -98,6 +98,8 @@
 
         void attach( fiber &);
 
+ void detach( fiber &);
+
         void switch_between( fiber &, fiber &);
 
         void enable_interruption( fiber &);

Modified: sandbox/fiber/libs/fiber/doc/fiber_ref.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/fiber_ref.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/fiber_ref.qbk 2009-11-28 15:38:08 EST (Sat, 28 Nov 2009)
@@ -945,6 +945,7 @@
                 fiber master_fiber;
 
                 void attach( fiber &);
+ void detach( fiber &);
 
                 void switch_between( fiber &, fiber &);
 
@@ -1001,6 +1002,18 @@
 [endsect]
 
 
+[section:detach Protected member function `detach( fiber &)`]
+
+ void detach( fiber &);
+
+[variablelist
+[[Effects:] [Protected member function in order to unregister the scheduler in
+internal storage from the fiber.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+
 [section:switch_between Protected member function `switch_between( fiber &, fiber &)`]
 
         void switch_between( fiber & from, fiber & to);

Modified: sandbox/fiber/libs/fiber/src/round_robin.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/round_robin.cpp (original)
+++ sandbox/fiber/libs/fiber/src/round_robin.cpp 2009-11-28 15:38:08 EST (Sat, 28 Nov 2009)
@@ -27,6 +27,12 @@
         terminated_fibers_()
 {}
 
+round_robin::~round_robin()
+{
+ BOOST_FOREACH( container::value_type va, fibers_)
+ { detach( va.second.f); }
+}
+
 void
 round_robin::add( fiber f)
 {

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 15:38:08 EST (Sat, 28 Nov 2009)
@@ -85,6 +85,7 @@
 {
         fiber * active( active_fiber.get() );
         if ( ! active) throw fiber_error("not a fiber");
+ if ( ! active->info_()->st) throw scheduler_error("no valid scheduler");
         active->info_()->st->yield( active->get_id() );
 }
 
@@ -93,6 +94,7 @@
 {
         fiber * active( active_fiber.get() );
         if ( ! active) throw fiber_error("not a fiber");
+ if ( ! active->info_()->st) throw scheduler_error("no valid scheduler");
         active->info_()->st->cancel( active->get_id() );
 }
 
@@ -113,6 +115,10 @@
 { f.info_()->st = this; }
 
 void
+strategy::detach( fiber & f)
+{ f.info_()->st = 0; }
+
+void
 strategy::switch_between( fiber & from, fiber & to)
 { from.switch_to_( to); }
 


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