Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58441 - in sandbox/fiber: . boost/fiber libs/fiber/doc libs/fiber/src
From: oliver.kowalke_at_[hidden]
Date: 2009-12-17 17:17:50


Author: olli
Date: 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
New Revision: 58441
URL: http://svn.boost.org/trac/boost/changeset/58441

Log:
- default stacksize 8kB
- docu updated

Added:
   sandbox/fiber/libs/fiber/doc/spin_barrier.qbk (contents, props changed)
   sandbox/fiber/libs/fiber/doc/spin_condition_variables.qbk (contents, props changed)
   sandbox/fiber/libs/fiber/doc/spin_event_variables.qbk (contents, props changed)
   sandbox/fiber/libs/fiber/doc/spin_fifos.qbk (contents, props changed)
   sandbox/fiber/libs/fiber/doc/spin_mutexes.qbk (contents, props changed)
   sandbox/fiber/libs/fiber/doc/spin_synchronization.qbk (contents, props changed)
   sandbox/fiber/libs/fiber/doc/synchronization.qbk (contents, props changed)
Text files modified:
   sandbox/fiber/boost/fiber/fiber.hpp | 2
   sandbox/fiber/change.log | 2
   sandbox/fiber/libs/fiber/doc/acknowledgements.qbk | 2
   sandbox/fiber/libs/fiber/doc/barrier.qbk | 15
   sandbox/fiber/libs/fiber/doc/condition_variables.qbk | 10
   sandbox/fiber/libs/fiber/doc/event_variables.qbk | 90 ++----
   sandbox/fiber/libs/fiber/doc/fiber.qbk | 24
   sandbox/fiber/libs/fiber/doc/fiber_ref.qbk | 526 +++++++++++----------------------------
   sandbox/fiber/libs/fiber/doc/fifos.qbk | 162 +++++-------
   sandbox/fiber/libs/fiber/doc/mutexes.qbk | 13
   sandbox/fiber/libs/fiber/doc/overview.qbk | 38 +-
   sandbox/fiber/libs/fiber/doc/todo.qbk | 8
   sandbox/fiber/libs/fiber/src/round_robin.cpp | 14
   13 files changed, 316 insertions(+), 590 deletions(-)

Modified: sandbox/fiber/boost/fiber/fiber.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/fiber.hpp (original)
+++ sandbox/fiber/boost/fiber/fiber.hpp 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -31,7 +31,7 @@
 namespace boost {
 namespace fibers {
 
-#define BOOST_FIBER_DEFAULT_STACKSIZE 64000
+#define BOOST_FIBER_DEFAULT_STACKSIZE 8192
 
 template< typename Strategy >
 class scheduler;

Modified: sandbox/fiber/change.log
==============================================================================
--- sandbox/fiber/change.log (original)
+++ sandbox/fiber/change.log 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -1,6 +1,8 @@
 0.3.1:
 ------
 - scheduler< Strategy >::migrate_fiber() overloaded - passing only fiber to be migrated
+- default stacksize set to 8kB
+- documetnation updated
 
 0.3.0:
 ------

Modified: sandbox/fiber/libs/fiber/doc/acknowledgements.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/acknowledgements.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/acknowledgements.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -3,8 +3,6 @@
  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
-
- Based on documentation from Boost.Thread.
 ]
 
 [section:acknowledgements Acknowledgments]

Modified: sandbox/fiber/libs/fiber/doc/barrier.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/barrier.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/barrier.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -12,7 +12,7 @@
 fibers reach the barrier they must wait until all `n` fibers have arrived. Once the `n`-th fiber has reached the
 barrier, all the waiting fibers can proceed, and the barrier is reset.
 
-[note __barrier__ is bound to a given __scheduler__ and can only be used by fibers managed by this scheduler.]
+[note __barrier__ is bound to the __scheduler__ passed to the constructor and can only be used by fibers managed by this scheduler.]
 
 [section:barrier Class `barrier`]
 
@@ -21,7 +21,7 @@
     class barrier
     {
     public:
- template< typename Strategy >
+ template< typename Strategy >
         barrier( scheduler< Strategy > & sched, uint32_t initial);
 
         bool wait();
@@ -29,21 +29,14 @@
 
 Instances of __barrier__ are not copyable or movable.
 
-[section:constructor Constructor]
-
- template< typename Strategy >
- barrier( scheduler< Strategy > & sched, uint32_t initial);
-
+[section:constructor `template< typename Strategy > barrier( scheduler< Strategy > & sched, uint32_t initial)`]
 [variablelist
 [[Effects:] [Construct a barrier for `initial` fibers.]]
 [[Throws:] [__invalid_argument__ if an error occurs.]]
 ]
 [endsect]
 
-[section:wait Member function `wait`]
-
- bool wait();
-
+[section:wait `bool wait()`]
 [variablelist
 [[Effects:] [Block until `initial` fibers have called `wait` on `*this`. When the `initial`-th fiber calls `wait`,
 all waiting fibers are unblocked, and the barrier is reset. ]]

Modified: sandbox/fiber/libs/fiber/doc/condition_variables.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/condition_variables.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/condition_variables.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -14,7 +14,7 @@
 condition is not true, then the fiber then calls `wait` again to resume waiting. In the simplest case, this
 condition is just a boolean variable:
 
- boost::fibers::scheduler<> sched;
+ boost::fibers::scheduler<> sched;
     boost::fibers::condition cond( sched);
     boost::fibers::mutex mtx( sched);
     bool data_ready;
@@ -56,7 +56,7 @@
 Note that the same mutex is locked before the shared data is updated, but that the mutex does not have to be locked
 across the call to `notify_one`.
 
-[note __condition__ is bound to a given __scheduler__ an can only be used by fibers managed by this scheduler.]
+[note __condition__ is bound to the __scheduler__ passed to the construtor and can only be used by fibers managed by this scheduler.]
 
 [section:condition Class `condition`]
 
@@ -65,7 +65,7 @@
     class condition
     {
     public:
- template< typename Strategy >
+ < typename Strategy >
         condition( scheduler< Strategy > & sched);
         ~condition();
 
@@ -77,14 +77,14 @@
         template< typename Pred >
         void wait( boost::unique_lock< boost::fibers::mutex > & lk, Pred pred);
 
- template< typename LockType >
+ template< typename LockType >
         void wait( LockType & lk);
 
         template< typename LockType, typename Pred >
         void wait( LockType & lk, Pred predicate);
     };
 
-[section:constructor `condition()`]
+[section:constructor `template< typename Strategy > condition( scheduler< Strategy > & sched)`]
 [variablelist
 [[Effects:] [Constructs an object of class `condition`.]]
 [[Throws:] [Nothing.]]

Modified: sandbox/fiber/libs/fiber/doc/event_variables.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/event_variables.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/event_variables.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -12,10 +12,11 @@
 __boost_fiber__ provides event variables to facilitate coordination between fibers.
 A event-variable has two states `set` (`signaled`) or `reset` (`nonsignaled`).
 
-[note event-variables are bound to a given __scheduler__ an can only be used by fibers
+[note event-variables are bound to the __scheduler__ passed to the constructor and can only be used by fibers
 managed by this scheduler.]
 
- boost::fibers::auto_reset_event ev;
+ boost::fibers::scheduler<> sched;
+ boost::fibers::auto_reset_event ev( sched);
 
     void process_data();
 
@@ -44,12 +45,19 @@
 
 [section:auto_reset_event Class `auto_reset_event`]
 
+[heading Synopsis]
+
+When the ['auto_reset_event] gets signaled, any one fiber will see this particular signal. When a fiber observes
+the signal by waiting on the event, it is automatically transitioned back to non-signaled state. Any fibers can
+subsequently set the event.
+
     #include <boost/fiber/auto_reset_event.hpp>
 
     class auto_reset_event : private boost::noncopyable
     {
     public:
- explicit auto_reset_event( bool isset = false);
+ template< typename Strategy >
+ explicit auto_reset_event( scheduler< Strategy > & sched, bool isset = false);
 
         ~auto_reset_event();
 
@@ -60,10 +68,7 @@
         bool try_wait();
     };
 
-[section:constructor `auto_reset_event()`]
-
- explicit auto_reset_event( bool isset = false);
-
+[section:constructor `template< typename Strategy > explicit auto_reset_event( scheduler< Strategy > & sched, bool isset = false)`]
 [variablelist
 [[Effects:] [Constructs an object of class `auto_reset_event`. If isset is `true`
 the variable is set.]]
@@ -72,9 +77,6 @@
 [endsect]
 
 [section:destructor `~auto_reset_event()`]
-
- ~auto_reset_event();
-
 [variablelist
 [[Precondition:] [All fibers waiting on `*this` have been notified by a call to
 `set` (though the respective calls to `wait` need not have returned).]]
@@ -84,9 +86,6 @@
 [endsect]
 
 [section:set `void set()`]
-
- void set();
-
 [variablelist
 [[Effects:] [If any fibers are currently __blocked__ waiting on `*this` in a call
 to `wait`, unblocks one of those fibers.]]
@@ -95,9 +94,6 @@
 [endsect]
 
 [section:wait `void wait()`]
-
- void wait();
-
 [variablelist
 [[Effects:] [Blocks the current fiber. The fiber will unblock when notified by a call
 to `this->set()`. When the fiber is unblocked, the variable is reset before `wait`
@@ -108,9 +104,6 @@
 [endsect]
 
 [section:try_wait `bool try_wait()`]
-
- bool try_wait();
-
 [variablelist
 [[Effects:] [Returns `true` if the event variable is set otherwise `false`.]]
 [[Throws:] [Nothing.]]
@@ -122,12 +115,18 @@
 
 [section:manual_reset_event Class `manual_reset_event`]
 
+[heading Synopsis]
+
+The ['manual_reset_event] remains signaled until it is manually reset. Multiple fibers
+wait on the same event and observe the same signal.
+
     #include <boost/fiber/manual_reset_event.hpp>
 
     class manual_reset_event : private boost::noncopyable
     {
     public:
- explicit manual_reset_event( bool isset = false);
+ template< typename Strategy >
+ explicit manual_reset_event( scheduler< Strategy > & sched, bool isset = false);
 
         ~manual_reset_event();
 
@@ -140,10 +139,7 @@
         bool try_wait();
     };
 
-[section:constructor `manual_reset_event()`]
-
- explicit manual_reset_event( bool isset = false);
-
+[section:constructor `template< typename Strategy > explicit manual_reset_event( scheduler< Strategy > & sched, bool isset = false)`]
 [variablelist
 [[Effects:] [Constructs an object of class `manual_reset_event`. If isset is `true`
 the variable is set.]]
@@ -152,9 +148,6 @@
 [endsect]
 
 [section:destructor `~manual_reset_event()`]
-
- ~manual_reset_event();
-
 [variablelist
 [[Precondition:] [All fibers waiting on `*this` have been notified by a call to
 `set` (though the respective calls to `wait` need not have returned).]]
@@ -164,9 +157,6 @@
 [endsect]
 
 [section:set `void set()`]
-
- void set();
-
 [variablelist
 [[Effects:] [If any fibers are currently __blocked__ waiting on `*this` in a call
 to `wait`, unblocks those fibers. The variable remains signaled until `this->reset()`
@@ -176,9 +166,6 @@
 [endsect]
 
 [section:reset `void reset()`]
-
- void reset();
-
 [variablelist
 [[Effects:] [The event variable gets nonsignaled and fibers calling `this->wait()`
 will block.]]
@@ -187,9 +174,6 @@
 [endsect]
 
 [section:wait `void wait()`]
-
- void wait();
-
 [variablelist
 [[Effects:] [Blocks the current fiber. The fiber will unblock when notified by a call
 to `this->set()`. When the fiber is unblocked, the variable remains set.]]
@@ -199,9 +183,6 @@
 [endsect]
 
 [section:trywait `boo try_wait()`]
-
- bool try_wait();
-
 [variablelist
 [[Effects:] [Returns `true` if the event variable is set otherwise `false`.]]
 [[Throws:] [Nothing.]]
@@ -213,12 +194,18 @@
 
 [section:count_down_event Class `count_down_event`]
 
+[heading Synopsis]
+
+The ['count_down_event] decrements an internal counter (set in the constructor) and all
+waiting fibers are blocked until the count reaches zero.
+
     #include <boost/fiber/count_down_event.hpp>
 
     class count_down_event : private boost::noncopyable
     {
     public:
- explicit count_down_event( uint32_t);
+ template< typename Strategy >
+ explicit count_down_event( scheduler< Strategy > & sched, uint32_t initial);
 
         ~count_down_event();
 
@@ -233,10 +220,7 @@
         void wait();
     };
 
-[section:constructor `count_down_event( uint32_t)`]
-
- explicit count_down_event( uint32_t initial);
-
+[section:constructor `template< typename Strategy > explicit count_down_event( scheduler< Strategy > & sched, uint32_t initial)`]
 [variablelist
 [[Effects:] [Constructs an object of class `count_down_event` with initial value.]]
 [[Throws:] [Nothing.]]
@@ -244,9 +228,6 @@
 [endsect]
 
 [section:destructor `~count_down_event()`]
-
- ~count_down_event();
-
 [variablelist
 [[Precondition:] [All fibers waiting on `*this` have been notified by a call to
 `set` (though the respective calls to `wait` need not have returned).]]
@@ -256,9 +237,6 @@
 [endsect]
 
 [section:initial `uint32_t initial()`]
-
- uint32_t initial();
-
 [variablelist
 [[Effects:] [Returns the initial value the event variable was initialized with.]]
 [[Throws:] [Nothing.]]
@@ -266,9 +244,6 @@
 [endsect]
 
 [section:current `uint32_t current()`]
-
- uint32_t current();
-
 [variablelist
 [[Effects:] [Returns the value the variable currently holds.]]
 [[Throws:] [Nothing.]]
@@ -276,9 +251,6 @@
 [endsect]
 
 [section:is_set `bool is_set()`]
-
- bool is_set();
-
 [variablelist
 [[Effects:] [Returns `true` if the varaible has reached zero.]]
 [[Throws:] [Nothing.]]
@@ -286,9 +258,6 @@
 [endsect]
 
 [section:set `void set()`]
-
- void set();
-
 [variablelist
 [[Effects:] [Decrements the current count. If the count reaches zero and any fibers are
 currently __blocked__ waiting on `*this` in a call to `wait`, unblocks those fibers.
@@ -298,9 +267,6 @@
 [endsect]
 
 [section:wait `void wait()`]
-
- void wait();
-
 [variablelist
 [[Effects:] [Blocks the current fiber. The fiber will unblock when notified by a call
 to `this->set()` and the count of the event variable reaches zero. When the fiber is

Modified: sandbox/fiber/libs/fiber/doc/fiber.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/fiber.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/fiber.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -30,9 +30,11 @@
 [template mutex_link[link_text] [link fiber.synchronization.mutex_types.mutex [link_text]]]
 [template scheduler_link[link_text] [link fiber.fiber_management.scheduler [link_text]]]
 [template strategy_link[link_text] [link fiber.fiber_management.strategy [link_text]]]
-[template round_robin_link[link_text] [link fiber.fiber_management.round_robin [link_text]]]
+[template round_robin_link[link_text] [link fiber.fiber_management.strategy.round_robin [link_text]]]
 
 [template auto_reset_wait_link[link_text] [link fiber.synchronization.eventvar_ref.auto_reset_event.wait [link_text]]]
+[template manual_reset_wait_link[link_text] [link fiber.synchronization.eventvar_ref.manual_reset_event.wait [link_text]]]
+[template count_down_wait_link[link_text] [link fiber.synchronization.eventvar_ref.count_down_event.wait [link_text]]]
 [template cond_wait_link[link_text] [link fiber.synchronization.conditions.condition.wait [link_text]]]
 [template interrupt_link[link_text] [link fiber.fiber_management.fiber.interrupt [link_text]]]
 [template join_link[link_text] [link fiber.fiber_management.fiber.join [link_text]]]
@@ -42,6 +44,7 @@
 [template interr_point_link[link_text] [link fiber.fiber_management.this_fiber.interruption_point [link_text]]]
 [template disable_interr_link[link_text] [link fiber.fiber_management.this_fiber.disable_interruption [link_text]]]
 [template restore_interr_link[link_text] [link fiber.fiber_management.this_fiber.restore_interruption [link_text]]]
+[template interr_points_link[link_text] [link fiber.fiber_management.predefined_interruption_points [link_text]]]
 
 [def __blocked__ ['blocked]]
 [def __not_a_fiber__ ['not-a-fiber]]
@@ -52,14 +55,18 @@
 [def __condition__ [condition_link ['condition]]]
 [def __fiber__ [fiber_link ['fiber]]]
 [def __fiber_id__ [fiber_id_link ['fiber-id]]]
+[def __interruption_points__ [interr_points_link ['interruption points]]]
 [def __mutex__ [mutex_link ['mutex]]]
-[def __scheduler__ scheduler_link['scheduler]]
-[def __strategy__ strategy_link['strategy]]
-[def __round_robin__ round_robin_link['round_robin]]
+[def __scheduler__ [scheduler_link ['scheduler]]]
+[def __strategy__ [strategy_link ['strategy]]]
+[def __round_robin__ [round_robin_link ['round_robin]]]
 
 [def __cond_wait__ [cond_wait_link `wait()`]]
 [def __interrupt__ [interrupt_link `interrupt()`]]
 [def __join__ [join_link `join()`]]
+[def __lock__ `lock()`]
+[def __try_lock__ `try_lock()`]
+[def __unlock__ `unlock()`]
 
 [def __interruption_enabled__ [interr_enabled_link `boost::this_fiber::interruption_enabled()`]]
 [def __interruption_requested__ [interr_requested_link `boost::this_fiber::interruption_requested()`]]
@@ -78,12 +85,7 @@
 
 [include overview.qbk]
 [include fiber_ref.qbk]
-[section:synchronization Synchronization]
-[include mutexes.qbk]
-[include condition_variables.qbk]
-[include barrier.qbk]
-[include event_variables.qbk]
-[include fifos.qbk]
-[endsect]
+[include synchronization.qbk]
+[include spin_synchronization.qbk]
 [include todo.qbk]
 [include acknowledgements.qbk]

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-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -16,8 +16,8 @@
 
         void f()
         {
- boost::fiber f1=boost::fibers::make_fiber( some_fn);
- boost::fiber f2=boost::fibers::make_fiber( another_fn);
+ boost::fiber f1( boost::fibers::make_fiber( some_fn) );
+ boost::fiber f2( boost::fibers::make_fiber( another_fn) );
 
                 boost::fibers::scheduler<> s;
                 s.submit( f1); // f1 gets copied
@@ -28,7 +28,7 @@
         }
 
 
-[heading Launching fibers]
+[heading Launching]
 
 A new fiber is launched by passing an object of a callable type that can be invoked with no parameters to the
 constructor and submiting the fiber (copy- or move-op.) to an instance of __scheduler__. The object is then copied
@@ -64,7 +64,7 @@
 
 For convinience `boost::fibers::make_fiber()` is provided:
 
- boost::fiber f = boost::fibers::make_fiber( new_fn, arg1, arg2, arg3);
+ boost::fiber f( boost::fibers::make_fiber( new_fn, arg1, arg2, arg3) );
 
 Another alternative is to use `scheduler<>::make_fiber()` which creates and stores the new fiber inside the scheduler.
 
@@ -72,13 +72,12 @@
         sched.make_fiber( new_fn, arg1, arg2, arg3);
 
 
-[heading Exceptions in fiber functions]
+[heading Exceptions]
 
 Exceptions thrown by the function or callable object passed to the __fiber__ constructor are consumed by the
-framework (if it required to know whichexceptions was thrown __boost_task__ should be used together with
-__boost_fiber__).
+framework (if it required to know which exceptions was thrown use __future__ and __packaged_task__).
 
-[warning Don't use sjlj exception model.]
+[warning Don't use the sjlj exception model.]
 
 [heading Joining]
 
@@ -151,8 +150,6 @@
 
 At any point, the interruption state for the current fiber can be queried by calling __interruption_enabled__.
 
-[#interruption_points]
-
 
 [heading Predefined Interruption Points]
 
@@ -251,24 +248,14 @@
         fiber make_fiber( std::size_t stack_size, Fn fn, A1 a1, A2 a2,...);
 
 
-[section:default_constructor Default Constructor]
-
- fiber();
-
+[section:default_constructor `fiber()`]
 [variablelist
 [[Effects:] [Constructs a __fiber__ instance that refers to __not_a_fiber__.]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:callable_constructor Fiber Constructor]
-
- template< typename Callable >
- fiber( Callable fn);
-
- template< typename Callable >
- fiber( std::size_t stack_size, Callable fn);
-
+[section:callable_constructor `template< typename Callable > fiber( Callable fn)`]
 [variablelist
 [[Preconditions:] [`Callable` must by copyable.]]
 [[Effects:] [`fn` is copied into storage managed internally by the fiber library, and that copy is invoked on a
@@ -278,14 +265,17 @@
 ]
 [endsect]
 
-[section:multiple_argument_constructor Fiber Constructor with arguments]
-
- template< typename Fn, typename A1, typename A2,...>
- fiber( Fn fn,A1 a1,A2 a2,...);
-
- template< typename Fn, typename A1, typename A2,...>
- fiber( std::size_t stack_size, Fn fn,A1 a1,A2 a2,...);
+[section:callable_constructor_stack `template< typename Callable > fiber( std::size_t stack_size, Callable fn)`]
+[variablelist
+[[Preconditions:] [`Callable` must by copyable.]]
+[[Effects:] [`fn` is copied into storage managed internally by the fiber library, and that copy is invoked on a
+newly-created fiber. Second version sets the stack-size of the fiber.]]
+[[Postconditions:] [`*this` refers to the newly created fiber.]]
+[[Throws:] [__system_error__ if system call failed.]]
+]
+[endsect]
 
+[section:multiple_argument_constructor `template< typename Fn, typename A1, typename A2,...> fiber( Fn fn, A1 a1, A2 a2,...)`]
 [variablelist
 [[Preconditions:] [`Fn` and each `A`n must by copyable or movable.]]
 [[Effects:] [As if `fiber( boost::bind( fn, a1, a2,...) )`. Consequently, `fn` and each `a`n
@@ -297,20 +287,26 @@
 ]
 [endsect]
 
-[section:destructor Fiber Destructor]
-
- ~fiber();
+[section:multiple_argument_constructor_stack `template< typename Fn, typename A1, typename A2,...> fiber( std::size_t stack_size, Fn fn, A1 a1, A2 a2,...)`]
+[variablelist
+[[Preconditions:] [`Fn` and each `A`n must by copyable or movable.]]
+[[Effects:] [As if `fiber( boost::bind( fn, a1, a2,...) )`. Consequently, `fn` and each `a`n
+are copied into internal storage for access by the new fiber.
+Second version additionaly sets the stack-size used by the fiber.]]
+[[Postconditions:] [`*this` refers to the newly created fiber.]]
+[[Throws:] [__system_error__ if system call failed.]]
+[[Note:] [Currently up to nine additional arguments `a1` to `a9` can be specified in addition to the function `fn`.]]
+]
+[endsect]
 
+[section:destructor `~fiber()`]
 [variablelist
 [[Effects:] [Destroys `*this`.]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:get_id Member function `get_id()`]
-
- fiber::id get_id() const;
-
+[section:get_id `fiber::id get_id() const`]
 [variablelist
 [[Returns:] [If `*this` refers to a fiber, an instance of __fiber_id__ that represents that fiber. Otherwise returns
 a default-constructed __fiber_id__.]]
@@ -318,10 +314,7 @@
 ]
 [endsect]
 
-[section:join Member function `join()`]
-
- void join();
-
+[section:join `void join()`]
 [variablelist
 [[Effects:] [Waits for `*this` to complete.]]
 [[Throws:] [__fiber_interrupted__ if the current fiber is interrupted and __system_error__
@@ -330,10 +323,7 @@
 ]
 [endsect]
 
-[section:interrupt Member function `interrupt()`]
-
- void interrupt();
-
+[section:interrupt `void interrupt()`]
 [variablelist
 [[Effects:] [If `*this` refers to a fiber, request that the fiber will be interrupted the next time it enters one of
 the predefined __interruption_points__ with interruption enabled, or if it is currently __blocked__ in a call to one
@@ -342,10 +332,7 @@
 ]
 [endsect]
 
-[section:interruption_requested Member function `interruption_requested()`]
-
- bool interruption_requested();
-
+[section:interruption_requested `bool interruption_requested()`]
 [variablelist
 [[Effects:] [If `*this` refers to a fiber, the function returns if the interruption of the fiber was already
 requested.]]
@@ -353,10 +340,7 @@
 ]
 [endsect]
 
-[section:cancel Member function `cancel()`]
-
- void cancel();
-
+[section:cancel `void cancel()`]
 [variablelist
 [[Effects:] [If `*this` refers to a fiber, request that the fiber will be canceled the next time it yields its
 execution.]]
@@ -364,10 +348,7 @@
 ]
 [endsect]
 
-[section:is_alive Member function `is_alive()`]
-
- bool is_alive();
-
+[section:is_alive `bool is_alive()`]
 [variablelist
 [[Effects:] [If `*this` refers to a fiber, the function returns false if the fiber is terminated or not started
 Otherwise it returns true.]]
@@ -376,49 +357,34 @@
 [endsect]
 
 [section:unspec_operator `operator unspecified-bool-type() const`]
-
- operator unspecified-bool-type() const;
-
 [variablelist
 [[Returns:] [If `*this` refers to a fiber, the function returns true. Otherwise false.]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:not_operator `operator!`]
-
- bool operator!() const;
-
+[section:not_operator `bool operator!() const`]
 [variablelist
 [[Returns:] [If `*this` refers not to a fiber, the function returns true. Otherwise false.]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:equals `operator==`]
-
- bool operator==(const fiber& other) const;
-
+[section:equals `bool operator==( fiber const& other) const`]
 [variablelist
 [[Returns:] [`get_id()==other.get_id()`]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:not_equals `operator!=`]
-
- bool operator!=(const fiber& other) const;
-
+[section:not_equals `bool operator!=( fiber const& other) const`]
 [variablelist
 [[Returns:] [`get_id()!=other.get_id()`]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:swap Member function `swap()`]
-
- void swap(fiber& other);
-
+[section:swap `void swap( fiber & other)`]
 [variablelist
 [[Effects:] [Exchanges the fibers associated with `*this` and `other`, so `*this` is associated with the fiber
 associated with `other` prior to the call, and vice-versa.]]
@@ -470,32 +436,26 @@
     public:
         id();
 
- bool operator==(const id& y) const;
- bool operator!=(const id& y) const;
- bool operator<(const id& y) const;
- bool operator>(const id& y) const;
- bool operator<=(const id& y) const;
- bool operator>=(const id& y) const;
-
- template<class charT, class traits>
- friend std::basic_ostream<charT, traits>&
- operator<<(std::basic_ostream<charT, traits>& os, const id& x);
+ bool operator==( id const& y) const;
+ bool operator!=( id const& y) const;
+ bool operator<( id const& y) const;
+ bool operator>( id const& y) const;
+ bool operator<=( id const& y) const;
+ bool operator>=( id const& y) const;
+
+ template< typename charT, typename traitsT >
+ friend std::basic_ostream< charT, traitsT > &
+ operator<<( std::basic_ostream<charT, traitsT > & os, id const& x);
     };
 
-[section:constructor Default constructor]
-
- id();
-
+[section:constructor `id()`]
 [variablelist
 [[Effects:] [Constructs a __fiber_id__ instance that represents __not_a_fiber__.]]
 [[Throws:] [Nothing]]
 ]
 [endsect]
 
-[section:is_equal `operator==`]
-
- bool operator==(const id& y) const;
-
+[section:is_equal `bool operator==( id const& y) const`]
 [variablelist
 [[Returns:] [`true` if `*this` and `y` both represent the same fiber of execution, or both represent __not_a_fiber__, `false`
 otherwise.]]
@@ -503,10 +463,7 @@
 ]
 [endsect]
 
-[section:not_equal `operator!=`]
-
- bool operator!=(const id& y) const;
-
+[section:not_equal `bool operator!=( id const& y) const`]
 [variablelist
 [[Returns:] [`true` if `*this` and `y` represent different fibers of execution, or one represents a fiber of execution, and
 the other represent __not_a_fiber__, `false` otherwise.]]
@@ -514,10 +471,7 @@
 ]
 [endsect]
 
-[section:less_than `operator<`]
-
- bool operator<(const id& y) const;
-
+[section:less_than `bool operator<( id const& y) const`]
 [variablelist
 [[Returns:] [`true` if `*this!=y` is `true` and the implementation-defined total order of __fiber_id__ values places `*this` before
 `y`, `false` otherwise.]]
@@ -527,41 +481,32 @@
 ]
 [endsect]
 
-[section:greater_than `operator>`]
-
- bool operator>(const id& y) const;
-
+[section:greater_than `bool operator>( id const& y) const`]
 [variablelist
 [[Returns:] [`y<*this`]]
 [[Throws:] [Nothing]]
 ]
 [endsect]
 
-[section:less_than_or_equal `operator>=`]
-
- bool operator<=(const id& y) const;
-
+[section:less_than_or_equal `bool operator<=( id const& y) const`]
 [variablelist
 [[Returns:] [`!(y<*this)`]]
 [[Throws:] [Nothing]]
 ]
 [endsect]
 
-[section:greater_than_or_equal `operator>=`]
-
- bool operator>=(const id& y) const;
-
+[section:greater_than_or_equal `bool operator>=( id const& y) const`]
 [variablelist
 [[Returns:] [`!(*this<y)`]]
 [[Throws:] [Nothing]]
 ]
 [endsect]
 
-[section:stream_out Friend `operator<<`]
+[section:stream_out Non-member template function `operator<<`]
 
- template<class charT, class traits>
- friend std::basic_ostream<charT, traits>&
- operator<<(std::basic_ostream<charT, traits>& os, const id& x);
+ template< typename charT, typename traitsT >
+ friend std::basic_ostream< charT, traitsT > &
+ operator<<( std::basic_ostream<charT, traitsT > & os, id const& x);
 
 [variablelist
 [[Effects:] [Writes a representation of the __fiber_id__ instance `x` to the stream `os`, such that the representation of two
@@ -666,6 +611,29 @@
 ]
 [endsect]
 
+[section:atfiberexit Non-member template function `at_fiber_exit()`]
+
+ #include <boost/fiber/utility.hpp>
+
+ template<typename Callable>
+ void at_fiber_exit(Callable func);
+
+[variablelist
+[[Effects:] [A copy of `func` is placed in
+fiber-specific storage. This copy is invoked when the current fiber
+exits (even if the fiber has been interrupted).]]
+[[Postconditions:] [A copy of `func` has been saved for invocation on fiber exit.]]
+[[Throws:] [`std::bad_alloc` if memory cannot be allocated for the copy of the function, __fiber_error__ if any other
+error occurs within the fiber library. Any exception thrown whilst copying `func` into internal storage.]]
+[[Note:] [This function is *not* called if the fiber was terminated
+forcefully using platform-specific APIs, or if the fiber is
+terminated due to a call to `exit()`, `abort()` or
+`std::terminate()`. In particular, returning from `main()` is
+equivalent to call to `exit()`, so will not call any functions
+registered with `at_fiber_exit()`]]
+]
+[endsect]
+
 [section:disable_interruption Class `disable_interruption`]
 
     #include <boost/fiber/interruption.hpp>
@@ -683,10 +651,7 @@
 `boost::this_fiber::disable_interruption` disables interruption for the current fiber on construction, and restores the prior
 interruption state on destruction. Instances of `disable_interruption` cannot be copied or moved.
 
-[section:constructor Constructor]
-
- disable_interruption();
-
+[section:constructor `disable_interruption()`]
 [variablelist
 [[Effects:] [Stores the current state of __interruption_enabled__ and disables interruption for the current fiber.]]
 [[Postconditions:] [__interruption_enabled__ returns `false` for the current fiber.]]
@@ -694,10 +659,7 @@
 ]
 [endsect]
 
-[section:destructor Destructor]
-
- ~disable_interruption();
-
+[section:destructor `~disable_interruption()`]
 [variablelist
 [[Preconditions:] [Must be called from the same fiber from which `*this` was constructed.]]
 [[Effects:] [Restores the current state of __interruption_enabled__ for the current fiber to that prior to the construction of `*this`.]]
@@ -726,10 +688,7 @@
 restored to the interruption state stored by the constructor of the supplied instance of __disable_interruption__. When the instance
 is destroyed, interruption is again disabled. Instances of `restore_interruption` cannot be copied or moved.
 
-[section:constructor Constructor]
-
- explicit restore_interruption(disable_interruption& disabler);
-
+[section:constructor `explicit restore_interruption(disable_interruption& disabler)`]
 [variablelist
 [[Preconditions:] [Must be called from the same fiber from which `disabler` was constructed.]]
 [[Effects:] [Restores the current state of __interruption_enabled__ for the current fiber to that prior to the construction of `disabler`.]]
@@ -738,10 +697,7 @@
 ]
 [endsect]
 
-[section:destructor Destructor]
-
- ~restore_interruption();
-
+[section:destructor `~restore_interruption()`]
 [variablelist
 [[Preconditions:] [Must be called from the same fiber from which `*this` was constructed.]]
 [[Effects:] [Disables interruption for the current fiber.]]
@@ -752,46 +708,25 @@
 
 [endsect]
 
-[section:atfiberexit Non-member function template `at_fiber_exit()`]
-
- #include <boost/fiber/utility.hpp>
-
- template<typename Callable>
- void at_fiber_exit(Callable func);
-
-[variablelist
-[[Effects:] [A copy of `func` is placed in
-fiber-specific storage. This copy is invoked when the current fiber
-exits (even if the fiber has been interrupted).]]
-[[Postconditions:] [A copy of `func` has been saved for invocation on fiber exit.]]
-[[Throws:] [`std::bad_alloc` if memory cannot be allocated for the copy of the function, __fiber_error__ if any other
-error occurs within the fiber library. Any exception thrown whilst copying `func` into internal storage.]]
-[[Note:] [This function is *not* called if the fiber was terminated
-forcefully using platform-specific APIs, or if the fiber is
-terminated due to a call to `exit()`, `abort()` or
-`std::terminate()`. In particular, returning from `main()` is
-equivalent to call to `exit()`, so will not call any functions
-registered with `at_fiber_exit()`]]
-]
-[endsect]
-
 [endsect]
 
 [section:scheduler Scheduler]
 
 [heading Synopsis]
 
-The template __scheduler__ is responsible for managing and scheduling of fibers passed to it. The scheduling-
+The template __scheduler__ is responsible for managing and scheduling of fibers passed to it. The scheduling
 algorithm is provided as an template argument to __scheduler__ (default is __round_robin__). The class implementing
 the scheduling algorithm must derive from class __strategy__. It is possible to migrate fibers between schedulers.
 
 [note If the fiber is not thread-affine (using thread-local-storage) it can be migrated to a scheduler running in
 another thread.]
 
+[warning The current implementation on Windows uses the Win32 Fiber API which does not allow to migrate fibers
+to other threads.]
+
 Usally __scheduler__ will be invoked until all fibers are scheduled and finished.
 
         boost::fibers::scheduler<> sched;
-
         sched.make_fiber( some_fn);
 
         for (;;)
@@ -840,10 +775,7 @@
         };
 
 
-[section:ctor Default Constructor]
-
- scheduler();
-
+[section:ctor `scheduler()`]
 [variablelist
 [[Effects:] [Creates an object of type scheduler< Strategy >.]]
 [[Throws:] [Nothing.]]
@@ -851,10 +783,7 @@
 [endsect]
 
 
-[section:dtor Destructor]
-
- ~scheduler();
-
+[section:dtor `~scheduler()`]
 [variablelist
 [[Effects:] [Detaches all managed fibers and destroys the scheduler.]]
 [[Throws:] [Nothing.]]
@@ -862,10 +791,7 @@
 [endsect]
 
 
-[section:run Member function `run()`]
-
- bool run();
-
+[section:run `bool run()`]
 [variablelist
 [[Effects:] [Executes a fiber from the internal storage and removes terminated fibers. The function returns
 `true` if a fiber could be executed or a terminated fiber could be removed - otherwise `false`.]]
@@ -873,74 +799,59 @@
 ]
 [endsect]
 
-[section:empty Member function `empty()`]
-
- bool empty();
-
+[section:empty `bool empty()`]
 [variablelist
 [[Effects:] [Returns `true` if the scheduler contains fibers (maybe runnable or waiting).]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:size Member function `size()`]
-
- std::size_t size();
-
+[section:size `std::size_t size()`]
 [variablelist
 [[Effects:] [Returns how many fibers the scheduler contains (maybe runnable or waiting).]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:submit_fiber Member function `submit_fiber( fiber f)`]
-
- void submit_fiber( fiber f);
-
+[section:submit_fiber `void submit_fiber( fiber f)`]
 [variablelist
 [[Effects:] [This function stores the passed fiber in the scheduler.]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:make_fiber Template member function `make_fiber()`]
-
- template< typename Fn >
- void make_fiber( Fn fn);
-
- template< typename Fn >
- void make_fiber( std::size_t stack_size, Fn fn);
-
- template< typename Fn, typename A1, typename A2,... >
- void make_fiber( Fn fn, A0 a0, A1 a1,...);
-
- template< typename Fn, typename A1, typename A2,... >
- void make_fiber( std::size_t stack_size, Fn fn, A1 a1, A2 a2,...);
-
+[section:make_fiber1 `template< typename Fn > void make_fiber( Fn fn)`]
 [variablelist
 [[Effects:] [The functions create a fiber which gets stored in the internal structures from scheduler.]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:migrate_fiber member function `migrate_fiber( fiber f)`]
+[section:make_fiber2 `template< typename Fn > void make_fiber( std::size_t stack_size, Fn fn)`]
+[variablelist
+[[Effects:] [The functions create a fiber which gets stored in the internal structures from scheduler.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
 
- void migrate_fiber( fiber f);
+[section:make_fiber3 `template< typename Fn, typename A1, typename A2,... > void make_fiber( Fn fn, A0 a0, A1 a1,...)`]
+[variablelist
+[[Effects:] [The functions create a fiber which gets stored in the internal structures from scheduler.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
 
+[section:migrate_fiber `void migrate_fiber( fiber f)`]
 [variablelist
 [[Effects:] [The fiber will be migrated to the scheduler.]]
-[[Throws:] [Throws __fiber_moved_, fiber_error, scheduler_error.]]
+[[Throws:] [Throws __fiber_moved__, fiber_error, scheduler_error.]]
 ]
 [endsect]
 
-[section:migrate_fiber_t Template member function `template< typename OtherStrategy > migrate_fiber( fiber::id const& id, scheduler< OtherStrategy > & sched)`]
-
- template< typename OtherStrategy >
- void migrate_fiber( fiber::id const& id, scheduler< OtherStrategy > & sched);
-
+[section:migrate_fiber_t `template< typename OtherStrategy > void migrate_fiber( fiber::id const& id, scheduler< OtherStrategy > & sched)`]
 [variablelist
 [[Effects:] [The fiber will be migrated to the scheduler.]]
-[[Throws:] [Throws __fiber_moved_, fiber_error, scheduler_error.]]
+[[Throws:] [Throws __fiber_moved__, fiber_error, scheduler_error.]]
 ]
 [endsect]
 
@@ -952,8 +863,8 @@
 
 [heading Synopsis]
 
-The template __scheduler__ accepts the implementation of the scheduling-algorithm as a template argument
-(currently round-robin is the choosen as the default).
+The template __scheduler__ accepts the implementation of the scheduling algorithm as a template argument
+(currently __round_robin__ is the choosen as the default).
 Each class destined to implement a scheduling algorithm must derive from __strategy__. The member `active_fiber`
 holds the current (running) fiber and `master_fiber` executes the scheduling logic.
 
@@ -967,8 +878,8 @@
         protected:
                 typedef thread_specific_ptr< fiber > active_fiber_t;
 
- static active_fiber_t active_fiber;
- fiber master_fiber;
+ static active_fiber_t active_fiber;
+ fiber master_fiber;
 
                 void attach( fiber &);
                 void detach( fiber &);
@@ -997,47 +908,27 @@
                 strategy();
 
                 virtual ~strategy();
-
                 virtual void add( fiber) = 0;
-
                 virtual void join( fiber::id const&) = 0;
-
                 virtual void interrupt( fiber::id const&) = 0;
-
                 virtual void reschedule( fiber::id const&) = 0;
-
                 virtual void cancel( fiber::id const&) = 0;
-
                 virtual void yield( fiber::id const&) = 0;
-
                 virtual void register_object( object::id const&) = 0;
-
                 virtual void unregister_object( object::id const&) = 0;
-
                 virtual void wait_for_object( object::id const&) = 0;
-
                 virtual void object_notify_one( object::id const&) = 0;
-
                 virtual void object_notify_all( object::id const&) = 0;
-
                 virtual fiber release( fiber::id const&) = 0;
-
                 virtual void migrate( fiber) = 0;
-
                 virtual void detach_all() = 0;
-
                 virtual bool run() = 0;
-
                 virtual bool empty() = 0;
-
                 virtual std::size_t size() = 0;
         };
 
 
-[section:attach Protected member function `attach( fiber &)`]
-
- void attach( fiber &);
-
+[section:attach `void attach( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function in order to register the scheduler in
 internal storage from the fiber.]]
@@ -1046,10 +937,7 @@
 [endsect]
 
 
-[section:detach Protected member function `detach( fiber &)`]
-
- void detach( fiber &);
-
+[section:detach `void detach( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function in order to unregister the scheduler in
 internal storage from the fiber.]]
@@ -1058,10 +946,7 @@
 [endsect]
 
 
-[section:switch_between Protected member function `switch_between( fiber &, fiber &)`]
-
- void switch_between( fiber & from, fiber & to);
-
+[section:switch_between `void switch_between( fiber & from, fiber & to)`]
 [variablelist
 [[Effects:] [Protected member function switches from fiber `from` to fiber `to`.]]
 [[Throws:] [Nothing.]]
@@ -1069,10 +954,7 @@
 [endsect]
 
 
-[section:enable_interruption Protected member function `enable_interruption( fiber &)`]
-
- void enable_interruption( fiber &);
-
+[section:enable_interruption `void enable_interruption( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function enables interruption on the fiber.]]
 [[Throws:] [Nothing.]]
@@ -1080,10 +962,7 @@
 [endsect]
 
 
-[section:interruption_enabled Protected member function `interruption_enabled( fiber const&)`]
-
- bool interruption_enabled( fiber const&);
-
+[section:interruption_enabled `bool interruption_enabled( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if interruption is enabled on the fiber.]]
 [[Throws:] [Nothing.]]
@@ -1091,10 +970,7 @@
 [endsect]
 
 
-[section:is_master Protected member function `is_master( fiber const&)`]
-
- bool is_master( fiber const&);
-
+[section:is_master `bool is_master( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if the fiber is the `master_fiber`.]]
 [[Throws:] [Nothing.]]
@@ -1102,10 +978,7 @@
 [endsect]
 
 
-[section:in_state_not_started Protected member function `in_state_not_started( fiber const&)`]
-
- bool in_state_not_started( fiber const&);
-
+[section:in_state_not_started `bool in_state_not_started( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if the fiber is in the state `started`.]]
 [[Throws:] [Nothing.]]
@@ -1113,10 +986,7 @@
 [endsect]
 
 
-[section:in_state_ready Protected member function `in_state_ready( fiber const&)`]
-
- bool in_state_ready( fiber const&);
-
+[section:in_state_ready `bool in_state_ready( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if the fiber is in the state `ready`.]]
 [[Throws:] [Nothing.]]
@@ -1124,10 +994,7 @@
 [endsect]
 
 
-[section:in_state_running Protected member function `in_state_running( fiber const&)`]
-
- bool in_state_running( fiber const&);
-
+[section:in_state_running `bool in_state_running( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if the fiber is in the state `running`.]]
 [[Throws:] [Nothing.]]
@@ -1135,10 +1002,7 @@
 [endsect]
 
 
-[section:in_state_wait_for_fiber Protected member function `in_state_wait_for_fiber( fiber const&)`]
-
- bool in_state_wait_for_fiber( fiber const&);
-
+[section:in_state_wait_for_fiber `bool in_state_wait_for_fiber( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if the fiber is in the state `wait for fiber`.]]
 [[Throws:] [Nothing.]]
@@ -1146,10 +1010,7 @@
 [endsect]
 
 
-[section:in_state_wait_for_object Protected member function `in_state_wait_for_object( fiber const&)`]
-
- bool in_state_wait_for_object( fiber const&);
-
+[section:in_state_wait_for_object `bool in_state_wait_for_object( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if the fiber is in the state `wait for object`.]]
 [[Throws:] [Nothing.]]
@@ -1157,10 +1018,7 @@
 [endsect]
 
 
-[section:in_state_terminated Protected member function `in_state_terminated( fiber const&)`]
-
- bool in_state_terminated( fiber const&);
-
+[section:in_state_terminated `bool in_state_terminated( fiber const&)`]
 [variablelist
 [[Effects:] [Protected member function tests if the fiber is in the state `terminated`.]]
 [[Throws:] [Nothing.]]
@@ -1168,10 +1026,7 @@
 [endsect]
 
 
-[section:set_state_ready Protected member function `set_state_ready( fiber &)`]
-
- void set_state_ready( fiber &);
-
+[section:set_state_ready `void set_state_ready( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function sets the state of the fiber to `ready`.]]
 [[Throws:] [Nothing.]]
@@ -1179,10 +1034,7 @@
 [endsect]
 
 
-[section:set_state_running Protected member function `set_state_running( fiber &)`]
-
- void set_state_running( fiber &);
-
+[section:set_state_running `void set_state_running( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function sets the state of the fiber to `running`.]]
 [[Throws:] [Nothing.]]
@@ -1190,10 +1042,7 @@
 [endsect]
 
 
-[section:set_state_wait_for_fiber Protected member function `set_state_wait_for_fiber( fiber &)`]
-
- void set_state_wait_for_fiber( fiber &);
-
+[section:set_state_wait_for_fiber `void set_state_wait_for_fiber( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function sets the state of the fiber to `wait for fiber`.]]
 [[Throws:] [Nothing.]]
@@ -1201,10 +1050,7 @@
 [endsect]
 
 
-[section:set_state_wait_for_object Protected member function `set_state_wait_for_object( fiber &)`]
-
- void set_state_wait_for_object( fiber &);
-
+[section:set_state_wait_for_object `void set_state_wait_for_object( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function sets the state of the fiber to `wait for object`.]]
 [[Throws:] [Nothing.]]
@@ -1212,10 +1058,7 @@
 [endsect]
 
 
-[section:set_state_terminated Protected member function `set_state_terminated( fiber &)`]
-
- void set_state_terminated( fiber &);
-
+[section:set_state_terminated `void set_state_terminated( fiber &)`]
 [variablelist
 [[Effects:] [Protected member function sets the state of the fiber to `terminated`.]]
 [[Throws:] [Nothing.]]
@@ -1223,10 +1066,7 @@
 [endsect]
 
 
-[section:ctor Default Constructor]
-
- strategy();
-
+[section:ctor `strategy()`]
 [variablelist
 [[Effects:] [Creates an object of type strategy and initializes the master_fiber member.]]
 [[Throws:] [Nothing.]]
@@ -1234,10 +1074,7 @@
 [endsect]
 
 
-[section:add Virtual member function `add( fiber)`]
-
- virtual void add( fiber) = 0;
-
+[section:add `virtual void add( fiber) = 0`]
 [variablelist
 [[Precondition:] [Fiber was not assigned to another scheduler.]]
 [[Effects:] [Add a fiber to the scheduler.]]
@@ -1245,10 +1082,7 @@
 [endsect]
 
 
-[section:join Virtual member function `join( fiber::id const&)`]
-
- virtual void join( fiber::id const&) = 0;
-
+[section:join `virtual void join( fiber::id const&) = 0`]
 [variablelist
 [[Precondition:] [Fiber belongs to this scheduler.]]
 [[Effects:] [The active fiber will yield until the fiber identified by the id has finished its
@@ -1257,10 +1091,7 @@
 [endsect]
 
 
-[section:interrupt Virtual member function `interrupt( fiber::id const&)`]
-
- virtual void interrupt( fiber::id const&) = 0;
-
+[section:interrupt `virtual void interrupt( fiber::id const&) = 0`]
 [variablelist
 [[Precondition:] [Fiber belongs to this scheduler.]]
 [[Effects:] [The fiber identified by the id will be interrupted by its next execution.]]
@@ -1268,10 +1099,7 @@
 [endsect]
 
 
-[section:reschedule Virtual member function `reschedule( fiber::id const&)`]
-
- virtual void reschedule( fiber::id const&) = 0;
-
+[section:reschedule `virtual void reschedule( fiber::id const&) = 0`]
 [variablelist
 [[Precondition:] [Fiber belongs to this scheduler.]]
 [[Effects:] [The scheduling-algorithm will be applied uppon the fiber identified by the id again.]]
@@ -1279,10 +1107,7 @@
 [endsect]
 
 
-[section:cancel Virtual member function `cancel( fiber::id const&)`]
-
- virtual void cancel( fiber::id const&) = 0;
-
+[section:cancel `virtual void cancel( fiber::id const&) = 0`]
 [variablelist
 [[Precondition:] [Fiber belongs to this scheduler.]]
 [[Effects:] [The fiber with passed identifier will be stopped, e.g. removed from the run-queue.]]
@@ -1290,10 +1115,7 @@
 [endsect]
 
 
-[section:yield Virtual member function `yield( fiber::id const&)`]
-
- virtual void yield( fiber::id const&) = 0;
-
+[section:yield `virtual void yield( fiber::id const&) = 0`]
 [variablelist
 [[Precondition:] [Fiber is the active fiber.]]
 [[Effects:] [Yield active fiber and switch back to `master_fiber` in order to schedule
@@ -1302,60 +1124,42 @@
 [endsect]
 
 
-[section:register_object Virtual member function `register_object( object::id const&)`]
-
- virtual void register_object( object::id const&) = 0;
-
+[section:register_object `virtual void register_object( object::id const&) = 0`]
 [variablelist
 [[Effects:] [Register the object (mutex, condition, event-variable).]]
 ]
 [endsect]
 
 
-[section:unregister_object Virtual member function `unregister_object( object::id const&)`]
-
- virtual void unregister_object( object::id const&) = 0;
-
+[section:unregister_object `virtual void unregister_object( object::id const&) = 0`]
 [variablelist
 [[Effects:] [Remove the object (mutex, condition, event-variable)i from the register.]]
 ]
 [endsect]
 
 
-[section:wait_for_object Virtual member function `wait_for_object( object::id const&)`]
-
- virtual void wait_for_object( object::id const&) = 0;
-
+[section:wait_for_object `virtual void wait_for_object( object::id const&) = 0`]
 [variablelist
 [[Effects:] [The active fiber waits on object until notified.]]
 ]
 [endsect]
 
 
-[section:object_notify_one Virtual member function `object_notify_one( object::id const&)`]
-
- virtual void object_notify_one( object::id const&) = 0;
-
+[section:object_notify_one `virtual void object_notify_one( object::id const&) = 0`]
 [variablelist
 [[Effects:] [Notify one fiber waiting on the object. The fiber gets ready for scheduling.]]
 ]
 [endsect]
 
 
-[section:object_notify_all Virtual member function `object_notify_all( object::id const&)`]
-
- virtual void object_notify_all( object::id const&) = 0;
-
+[section:object_notify_all `virtual void object_notify_all( object::id const&) = 0`]
 [variablelist
 [[Effects:] [Notify all fibers waiting on the object. The fibers get ready for scheduling.]]
 ]
 [endsect]
 
 
-[section:release Virtual member function `release( fiber::id const&)`]
-
- virtual void release( fiber::id const&) = 0;
-
+[section:release `virtual void release( fiber::id const&) = 0`]
 [variablelist
 [[Postcondition:] [The fiber is not terminated or waits on fiber or object.]]
 [[Effects:] [Release fiber from scheduler.]]
@@ -1363,10 +1167,7 @@
 [endsect]
 
 
-[section:migrate Virtual member function `migrate( fiber)`]
-
- virtual void migrate( fiber) = 0;
-
+[section:migrate `virtual void migrate( fiber) = 0`]
 [variablelist
 [[Postcondition:] [The fiber is not already managed by scheduler.]]
 [[Effects:] [Adds fiber to scheduler.]]
@@ -1374,21 +1175,14 @@
 [endsect]
 
 
-[section:detach_all Virtual member function `detach_all()`]
-
- virtual void detach_all() = 0;
-
+[section:detach_all `virtual void detach_all() = 0`]
 [variablelist
 [[Effects:] [Detaches all managed fibers from this.]]
 ]
 [endsect]
 
 
-
-[section:run Virtual member function `run()`]
-
- virtual bool run() = 0;
-
+[section:run `virtual bool run() = 0`]
 [variablelist
 [[Effects:] [Executes a fiber from the internal storage and removes terminated fibers. The function returns
 `true` if a fiber could be executed or a terminated fiber could be removed - otherwise `false`.]]
@@ -1396,20 +1190,14 @@
 ]
 [endsect]
 
-[section:empty Virtual member function `empty()`]
-
- virtual bool empty() = 0;
-
+[section:empty `virtual bool empty() = 0`]
 [variablelist
 [[Effects:] [Returns `true` if the scheduler contains fibers (maybe runnable or waiting).]]
 [[Throws:] [Nothing.]]
 ]
 [endsect]
 
-[section:size Virtual member function `size()`]
-
- virtual std::size_t size() = 0;
-
+[section:size `virtual std::size_t size() = 0`]
 [variablelist
 [[Effects:] [Returns how many fibers the scheduler contains (maybe runnable or waiting).]]
 [[Throws:] [Nothing.]]
@@ -1420,8 +1208,8 @@
 
 [section:round_robin Class `round_robin`]
 
-The class `round_robin` dervives from __strategy__ and implements a simple round-robin schduling-axpglorithm.
-It does not respect priorities offibers.
+The class `round_robin` derives from __strategy__ and implements a simple round-robin scheduling-algorithm.
+It does not respect priorities of fibers.
 
 [endsect]
 

Modified: sandbox/fiber/libs/fiber/doc/fifos.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/fifos.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/fifos.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -9,62 +9,60 @@
 
 __boost_fiber__ provides a bounded and a unbounded fifo suitable to synchonize fibers via message passing.
 
-[note fifos are bound to a given __scheduler__ an can only be used by fibers
+[note fifos are bound to the __scheduler__ passed to the construtor and can only be used by fibers
 managed by this scheduler.]
 
- typedef boost::fibers::unbounded_fifo< int > fifo_t;
+ typedef boost::fibers::unbounded_fifo< int > fifo_t;
 
- void send( fifo_t fifo)
- {
- for ( int i = 0; i < 5; ++i)
- fifo.put( i);
- fifo.deactivate();
- }
+ void send( fifo_t fifo)
+ {
+ for ( int i = 0; i < 5; ++i)
+ fifo.put( i);
+ fifo.deactivate();
+ }
+
+ void recv( fifo_t fifo)
+ {
+ boost::optional< int > value;
+ while ( fifo.take( value) )
+ { std::cout << "received " << * value << std::endl; }
+ }
+
+ boost::fibers::scheduler<> sched;
+ fifo_t fifo( sched);
+ sched.make_fiber( send, fifo);
+ sched.make_fiber( recv, fifo);
+
+ for (;;)
+ {
+ while ( sched.run() );
+ if ( sched.empty() ) break;
+ }
+
+
+[section:unbounded_fifo Template `template< typename T > unbounded_fifo`]
+
+ #include <boost/fiber/unbounded_fifo.hpp>
+
+ template< typename T >
+ class unbounded_fifo : private noncopyable
+ {
+ public:
+ template< typename Strategy >
+ unbounded_fifo( scheduler< Strategy > & sched);
 
- void recv( fifo_t fifo)
- {
- boost::optional< int > value;
- while ( fifo.take( value) )
- { std::cout << "received " << * value << std::endl; }
- }
-
- boost::fibers::scheduler<> sched;
- fifo_t fifo( sched);
- sched.make_fiber( send, fifo);
- sched.make_fiber( recv, fifo);
-
- for (;;)
- {
- while ( sched.run() );
- if ( sched.empty() ) break;
- }
-
-
-[section:unbounded_fifo Template `unbounded_fifo`]
-
- #include <boost/fiber/unbounded_fifo.hpp>
-
- template< typename T >
- class unbounded_fifo : private noncopyable
- {
- public:
- unbounded_fifo();
-
- void deactivate();
-
- bool empty();
-
- void put( T const& t);
+ void deactivate();
 
- bool take( boost::optional< T > & va);
+ bool empty();
 
- bool try_take( boost::optional< T > & va);
- };
+ void put( T const& t);
 
-[section:constructor `unbounded_fifo()`]
+ bool take( boost::optional< T > & va);
 
- unbounded_fifo();
+ bool try_take( boost::optional< T > & va);
+ };
 
+[section:constructor `template< typename Strategy > unbounded_fifo( scheduler< Strategy > & sched)`]
 [variablelist
 [[Effects:] [Constructs an object of class `unbounded_fifo`.]]
 [[Throws:] [Nothing.]]
@@ -72,9 +70,6 @@
 [endsect]
 
 [section:deactivate `void deactivate()`]
-
- void deactivate();
-
 [variablelist
 [[Effects:] [Deactivates the fifo. No values can be put after calling `this->deactivate`. Fibers blocked in
 `this->take()` will be return.]]
@@ -83,9 +78,6 @@
 [endsect]
 
 [section:empty `bool empty()`]
-
- bool empty();
-
 [variablelist
 [[Effects:] [Returns `true` if the fifo currently contains no data.]]
 [[Throws:] [Nothing.]]
@@ -93,9 +85,6 @@
 [endsect]
 
 [section:put `void put( T const& t)`]
-
- void put( T const& t);
-
 [variablelist
 [[Effects:] [Enqueues the value in the fifo and wakes up a fiber waiting for new data available from the
 fifo.]]
@@ -104,9 +93,6 @@
 [endsect]
 
 [section:take `bool take( boost::optional< T > & va)`]
-
- bool take( boost::optional< T > & va);
-
 [variablelist
 [[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the fiber gets suspended until
 new data are enqueued (return value `true` and va contains dequeued value) or the fifo gets deactiveted and
@@ -116,9 +102,6 @@
 [endsect]
 
 [section:try_take `bool try_take( boost::optional< T > & va)`]
-
- bool try_take( boost::optional< T > & va);
-
 [variablelist
 [[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the function returns `false`.
 Otherwise it returns `true` and `va` contains the dequed value.]]
@@ -129,33 +112,39 @@
 [endsect]
 
 
-[section:bounded_fifo Template `bounded_fifo`]
-
- #include <boost/fiber/bounded_fifo.hpp>
+[section:bounded_fifo Template `template< typename T > bounded_fifo`]
 
- template< typename T >
- class bounded_fifo : private noncopyable
- {
- public:
- unbounded_fifo( std::size_t wm);
+ #include <boost/fiber/bounded_fifo.hpp>
 
- unbounded_fifo( std::size_t hwm, std::size_t lwm);
+ template< typename T >
+ class bounded_fifo : private noncopyable
+ {
+ public:
+ template< typename Strategy >
+ bounded_fifo( scheduler< Strategy > & sched, std::size_t wm);
 
- void deactivate();
+ template< typename Strategy >
+ bounded_fifo( scheduler< Strategy > & sched, std::size_t hwm, std::size_t lwm);
 
- bool empty();
+ void deactivate();
 
- void put( T const& t);
+ bool empty();
 
- bool take( boost::optional< T > & va);
+ void put( T const& t);
 
- bool try_take( boost::optional< T > & va);
- };
+ bool take( boost::optional< T > & va);
 
-[section:constructor `bounded_fifo()`]
+ bool try_take( boost::optional< T > & va);
+ };
 
- bounded_fifo( std::size_t wm);
+[section:constructor `template< typename Strategy > bounded_fifo( scheduler< Strategy > & sched, std::size_t wm)`]
+[variablelist
+[[Effects:] [Constructs an object of class `bounded_fifo` which will contain a maximum of `wm` items.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
 
+[section:constructor2 `template< typename Strategy > bounded_fifo( scheduler< Strategy > & sched, std::size_t wm)`]
 [variablelist
 [[Effects:] [Constructs an object of class `bounded_fifo` which will contain a maximum of `wm` items.]]
 [[Throws:] [Nothing.]]
@@ -163,9 +152,6 @@
 [endsect]
 
 [section:deactivate `void deactivate()`]
-
- void deactivate();
-
 [variablelist
 [[Effects:] [Deactivates the fifo. No values can be put after calling `this->deactivate`. Fibers blocked in
 `this->take()` will be return.]]
@@ -174,9 +160,6 @@
 [endsect]
 
 [section:empty `bool empty()`]
-
- bool empty();
-
 [variablelist
 [[Effects:] [Returns `true` if the fifo currently contains no data.]]
 [[Throws:] [Nothing.]]
@@ -184,9 +167,6 @@
 [endsect]
 
 [section:put `void put( T const& t)`]
-
- void put( T const& t);
-
 [variablelist
 [[Effects:] [Enqueues the value in the fifo and wakes up a fiber waiting for new data available from the
 fifo. If the watermark has reached the fiber putting the value will be supended until at least one item
@@ -196,9 +176,6 @@
 [endsect]
 
 [section:take `bool take( boost::optional< T > & va)`]
-
- bool take( boost::optional< T > & va);
-
 [variablelist
 [[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the fiber gets suspended until
 new data are enqueued (return value `true` and va contains dequeued value) or the fifo gets deactiveted and
@@ -208,9 +185,6 @@
 [endsect]
 
 [section:try_take `bool try_take( boost::optional< T > & va)`]
-
- bool try_take( boost::optional< T > & va);
-
 [variablelist
 [[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the function returns `false`.
 Otherwise it returns `true` and `va` contains the dequed value.]]

Modified: sandbox/fiber/libs/fiber/doc/mutexes.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/mutexes.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/mutexes.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -14,21 +14,22 @@
     class mutex : private boost::noncopyable
     {
     public:
- mutex();
+ template< typename Strategy >
+ mutex( scheduler< Strategy > & sched);
         ~mutex();
-
+
         void lock();
         bool try_lock();
         void unlock();
 
- typedef unique_lock<mutex> scoped_lock;
+ typedef unique_lock< mutex > scoped_lock;
     };
 
 __mutex__ implements the __lockable_concept__ to provide an exclusive-ownership mutex. At most one fiber can own the
-lock on a given instance of __mutex__ at any time. Multiple concurrent calls to __lock_ref__, __try_lock_ref__ and
-__unlock_ref__ shall be permitted.
+lock on a given instance of __mutex__ at any time. Multiple concurrent calls to __lock__, __try_lock__ and
+__unlock__ shall be permitted.
 
-[note __mutex__ is bound to a given __scheduler__ an can only be used by fibers
+[note __mutex__ is bound to the __scheduler__ passed to the constructor and can only be used by fibers
 managed by this scheduler.]
 
 [endsect]

Modified: sandbox/fiber/libs/fiber/doc/overview.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/overview.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/overview.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -1,28 +1,28 @@
 [/
- (C) Copyright 2007-8 Anthony Williams.
- 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).
+ 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
 ]
 
 [section:overview Overview]
 
 __boost_fiber__ provides an framework utilizing lightweight threads of execution - also known
-as user-level/user-space threads or fibers (Win32 API). The API of the library is
-modeled after __boost_thread__ and contains classes, functions to manage fibers and to synchronize
-data between the fibers.
-
-A fiber owns a user-space stack, a context (processor register state) and is a lighter scheduling
-item which is scheduled cooperatively (threads are preemptively scheduled) - the running fiber
-decides explicitly when its yields to allow another fiber to run (fiber switching).
-Fibers are less expensive than threads because the kernel doesn't know anything about fibers -
-no kernel transitions are required for scheduling (done in the user-space). A context switch
-between threads costs usally thousends of CPU cycles on x86 compared to a fiber switch with few
-hundreds of cycles.
+as user-space threads, microthreads or fibers. The API of the library exposes an interface similiar
+to __boost_thread__ and contains classes, functions to manage fibers and to synchronize fibers.
+
+A fiber is able to store the current execution state, including all registers and CPU flags, the
+instruction pointer, and the stack pointer and later restore this state. The idea is to have multiple
+execution paths running on a single thread using a sort of cooperative scheduling (threads are
+preemptively scheduled) - the running fiber decides explicitly when its yields to allow another fiber
+to run (fiber switching). Fibers are less expensive than threads because the kernel doesn't know
+anything about fibers - no kernel transitions are required for scheduling (done in the user-space).
+A context switch between threads costs usally thousends of CPU cycles on x86 compared to a fiber
+switch with few hundreds of cycles.
 A fiber can only run on a single thread at any point in time but may be migrated between threads.
-Because a thread can run many different fibers during its life cycle the name __fiber__ was choosen.
+Because a thread can run many different fibers during its life cycle the name ['fiber] was choosen.
 
-Beside fibers conceptualy equivalent constructs are coroutines. A coroutine can be seen as a
+Beside fibers a conceptualy equivalent constructs are coroutines. A coroutine can be seen as a
 language-level construct while a fiber is a system-level construct.
 
 In order to use the classes and functions described here, you can either include the specific
@@ -38,8 +38,6 @@
 
 [warning This library is NOT an official Boost library]
 
-[note Please note that __boost_fiber__ is not optimized yet.]
-
 
 [heading Tested Platforms]
 
@@ -47,7 +45,7 @@
 
 * Debian GNU/Linux 2.6.31.6 (x86_64), GCC 4.3.4
 * Ubuntu GNU/Linux 2.6.28.11 (x86), GCC 4.3.3
-* FreeBSD 7.2 (x86), GCC 4.2.1
+* FreeBSD 8.0 (x86), GCC 4.2.1
 * OpenSolaris 2009.06 (x86_64), GCC 4.3.2
 * Windows XP Professional (x86), MSVC 9.0
 

Added: sandbox/fiber/libs/fiber/doc/spin_barrier.qbk
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/doc/spin_barrier.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -0,0 +1,57 @@
+[/
+ (C) Copyright 2007-8 Anthony Williams.
+ 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).
+]
+
+[section:barriers Barriers]
+
+A barrier is a simple concept. Also known as a __rendezvous__, it is a synchronization point between multiple
+contexts of execution (thread or fiber). The barrier is configured for a particular number of fibers (`n`), and as
+fibers reach the barrier they must wait until all `n` fibers have arrived. Once the `n`-th fiber has reached the
+barrier, all the waiting fibers can proceed, and the barrier is reset.
+
+[note __barrier__ is bound to a given __scheduler__ and can only be used by fibers managed by this scheduler.]
+
+[section:barrier Class `barrier`]
+
+ #include <boost/fiber/barrier.hpp>
+
+ class barrier
+ {
+ public:
+ template< typename Strategy >
+ barrier( scheduler< Strategy > & sched, uint32_t initial);
+
+ bool wait();
+ };
+
+Instances of __barrier__ are not copyable or movable.
+
+[section:constructor Constructor]
+
+ template< typename Strategy >
+ barrier( scheduler< Strategy > & sched, uint32_t initial);
+
+[variablelist
+[[Effects:] [Construct a barrier for `initial` fibers.]]
+[[Throws:] [__invalid_argument__ if an error occurs.]]
+]
+[endsect]
+
+[section:wait Member function `wait`]
+
+ bool wait();
+
+[variablelist
+[[Effects:] [Block until `initial` fibers have called `wait` on `*this`. When the `initial`-th fiber calls `wait`,
+all waiting fibers are unblocked, and the barrier is reset. ]]
+[[Returns:] [`true` for exactly one fiber from each batch of waiting fibers, `false` otherwise.]]
+[[Throws:] [__fiber_error__ if an error occurs.]]
+]
+[endsect]
+
+[endsect]
+
+[endsect]

Added: sandbox/fiber/libs/fiber/doc/spin_condition_variables.qbk
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/doc/spin_condition_variables.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -0,0 +1,178 @@
+[/
+ (C) Copyright 2007-8 Anthony Williams.
+ 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).
+]
+
+[section:conditions Condition Variables using spinwait]
+
+[heading Synopsis]
+
+The class `condition` provides a mechanism for one fiber to wait for notification `condition`. When the fiber is
+woken from the wait, then it checks to see if the appropriate condition is now true, and continues if so. If the
+condition is not true, then the fiber then calls `wait` again to resume waiting. In the simplest case, this
+condition is just a boolean variable:
+
+ boost::fibers::spin::condition cond;
+ boost::fibers::spin::mutex mtx;
+ bool data_ready;
+
+ void process_data();
+
+ void wait_for_data_to_process()
+ {
+ boost::unique_lock< boost::fibers::spin::mutex > lk( mtx);
+ while ( ! data_ready)
+ {
+ cond.wait( lk);
+ }
+ process_data();
+ }
+
+Notice that the `lk` is passed to `wait`: `wait` will atomically add the fiber to the set of fibers waiting on the
+condition variable, and unlock the mutex. When the fiber is woken, the mutex will be locked again before the call
+to `wait` returns. This allows other fibers to acquire the mutex in order to update the shared data, and ensures
+that the data associated with the condition is correctly synchronized.
+
+In the mean time, another fiber sets the condition to `true`, and then calls either `notify_one` or `notify_all` on
+the condition variable to wake one waiting fiber or all the waiting fibers respectively.
+
+ void retrieve_data();
+ void prepare_data();
+
+ void prepare_data_for_processing()
+ {
+ retrieve_data();
+ prepare_data();
+ {
+ boost::lock_guard< boost::fibers::mutex > lk( mtx);
+ data_ready = true;
+ }
+ cond.notify_one();
+ }
+
+Note that the same mutex is locked before the shared data is updated, but that the mutex does not have to be locked
+across the call to `notify_one`.
+
+[note __condition__ is [*not] bound to a __scheduler__ an can be used to synchronize fibers managed by different schedulers.]
+
+[section:condition Class `condition`]
+
+ #include <boost/fiber/spin/condition.hpp>
+
+ class condition
+ {
+ public:
+ condition();
+ ~condition();
+
+ void notify_one();
+ void notify_all();
+
+ void wait( boost::unique_lock< boost::fibers::mutex > & lk);
+
+ template< typename Pred >
+ void wait( boost::unique_lock< boost::fibers::spin::mutex > & lk, Pred pred);
+
+ template< typename LockType >
+ void wait( LockType & lk);
+
+ template< typename LockType, typename Pred >
+ void wait( LockType & lk, Pred predicate);
+ };
+
+[section:constructor `condition()`]
+[variablelist
+[[Effects:] [Constructs an object of class `condition`.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:destructor `~condition()`]
+[variablelist
+[[Precondition:] [All fibers waiting on `*this` have been notified by a call to `notify_one` or `notify_all`
+(though the respective calls to `wait` need not have returned).]]
+[[Effects:] [Destroys the object.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:notify_one `void notify_one()`]
+[variablelist
+[[Effects:] [If any fibers are currently __blocked__ waiting on `*this` in a call to `wait`, unblocks one of
+those fibers.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:notify_all `void notify_all()`]
+[variablelist
+[[Effects:] [If any fibers are currently __blocked__ waiting on `*this` in a call to `wait`, unblocks all of
+those fibers.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:wait `void wait( boost::unique_lock< boost::fibers::spin::mutex > & lk)`]
+[variablelist
+[[Precondition:] [`lk` is locked by the current fiber, and either no other
+fiber is currently waiting on `*this`, or the execution of the `mutex()` member
+function on the `lk` objects supplied in the calls to `wait` in all the fibers
+currently waiting on `*this` would return the same value as `lk->mutex()` for
+this call to `wait`.]]
+[[Effects:] [Atomically call `lk.unlock()` and blocks the current fiber. The
+fiber will unblock when notified by a call to `this->notify_one()` or
+`this->notify_all()`, or spuriously. When the fiber is unblocked (for whatever
+reason), the lock is reacquired by invoking `lk.lock()` before the call to
+`wait` returns. The lock is also reacquired by invoking `lk.lock()` if the
+function exits with an exception.]]
+[[Postcondition:] [`lk` is locked by the current fiber.]]
+[[Throws:] [__fiber_error__ if an error
+occurs. __fiber_interrupted__ if the wait was interrupted by a call to
+__interrupt__ on the __fiber__ object associated with the current fiber of execution.]]
+]
+[endsect]
+
+[section:wait_predicate `template< typename Pred > void wait( boost::unique_lock< boost::fibers::spin::mutex > & lk, Pred pred)`]
+[variablelist
+[[Effects:] [As-if ``
+while ( ! pred())
+{
+ wait( lk);
+}
+``]]
+
+]
+[endsect]
+
+[section:wait_t `template< typename LockType > void wait( LockType & lk)`]
+[variablelist
+[[Effects:] [Atomically call `lk.unlock()` and blocks the current fiber. The
+fiber will unblock when notified by a call to `this->notify_one()` or
+`this->notify_all()`, or spuriously. When the fiber is unblocked (for whatever
+reason), the lock is reacquired by invoking `lk.lock()` before the call to
+`wait` returns. The lock is also reacquired by invoking `lk.lock()` if the
+function exits with an exception.]]
+[[Postcondition:] [`lk` is locked by the current fiber.]]
+[[Throws:] [__fiber_error__ if an error
+occurs. __fiber_interrupted__ if the wait was interrupted by a call to
+__interrupt__ on the __fiber__ object associated with the current fiber of execution.]]
+]
+[endsect]
+
+[section:wait_predicate_t `template< typename LockType, typename Pred > void wait( LockType & lk, Pred pred)`]
+[variablelist
+[[Effects:] [As-if ``
+while ( ! pred())
+{
+ wait( lock);
+}
+``]]
+
+]
+[endsect]
+
+[endsect]
+
+[endsect]

Added: sandbox/fiber/libs/fiber/doc/spin_event_variables.qbk
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/doc/spin_event_variables.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -0,0 +1,315 @@
+[/
+ (C) Copyright 2007-8 Anthony Williams.
+ 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).
+]
+
+[section:eventvar_ref Event Variables using spinwait]
+
+[heading Synopsis]
+
+__boost_fiber__ provides event variables to facilitate coordination between fibers.
+A event-variable has two states `set` (`signaled`) or `reset` (`nonsignaled`).
+
+[note event-variables using spinwait are [*not] bound to a __scheduler__ an can be used to synchronize fibers
+managed by different schedulers.]
+
+ boost::fibers::auto_reset_event ev;
+
+ void process_data();
+
+ void wait_for_data_to_process()
+ {
+ ev.wait();
+ process_data();
+ }
+
+`wait` will atomically add the fiber to the set of fibers waiting on the event
+variable. When the fiber is woken, the event variable will be reset again.
+
+In the mean time, another fiber signals the event variable by calling
+`set` on the event variable to wake one waiting fiber.
+
+ void retrieve_data();
+ void prepare_data();
+
+ void prepare_data_for_processing()
+ {
+ retrieve_data();
+ prepare_data();
+ ev.set();
+ }
+
+
+[section:auto_reset_event Class `auto_reset_event`]
+
+ #include <boost/fiber/spin/auto_reset_event.hpp>
+
+ class auto_reset_event : private boost::noncopyable
+ {
+ public:
+ explicit auto_reset_event( bool isset = false);
+
+ ~auto_reset_event();
+
+ void set();
+
+ void wait();
+
+ bool try_wait();
+ };
+
+[section:constructor `auto_reset_event()`]
+
+ explicit auto_reset_event( bool isset = false);
+
+[variablelist
+[[Effects:] [Constructs an object of class `auto_reset_event`. If isset is `true`
+the variable is set.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:destructor `~auto_reset_event()`]
+
+ ~auto_reset_event();
+
+[variablelist
+[[Precondition:] [All fibers waiting on `*this` have been notified by a call to
+`set` (though the respective calls to `wait` need not have returned).]]
+[[Effects:] [Destroys the object.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:set `void set()`]
+
+ void set();
+
+[variablelist
+[[Effects:] [If any fibers are currently __blocked__ waiting on `*this` in a call
+to `wait`, unblocks one of those fibers.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:wait `void wait()`]
+
+ void wait();
+
+[variablelist
+[[Effects:] [Blocks the current fiber. The fiber will unblock when notified by a call
+to `this->set()`. When the fiber is unblocked, the variable is reset before `wait`
+returns.]]
+[[Throws:] [__fiber_interrupted__ if the wait was interrupted by a call to
+__interrupt__ on the __fiber__ object associated with the current fiber of execution.]]
+]
+[endsect]
+
+[section:try_wait `bool try_wait()`]
+
+ bool try_wait();
+
+[variablelist
+[[Effects:] [Returns `true` if the event variable is set otherwise `false`.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[endsect]
+
+
+[section:manual_reset_event Class `manual_reset_event`]
+
+ #include <boost/fiber/spin/manual_reset_event.hpp>
+
+ class manual_reset_event : private boost::noncopyable
+ {
+ public:
+ explicit manual_reset_event( bool isset = false);
+
+ ~manual_reset_event();
+
+ void set();
+
+ void reset();
+
+ void wait();
+
+ bool try_wait();
+ };
+
+[section:constructor `manual_reset_event()`]
+
+ explicit manual_reset_event( bool isset = false);
+
+[variablelist
+[[Effects:] [Constructs an object of class `manual_reset_event`. If isset is `true`
+the variable is set.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:destructor `~manual_reset_event()`]
+
+ ~manual_reset_event();
+
+[variablelist
+[[Precondition:] [All fibers waiting on `*this` have been notified by a call to
+`set` (though the respective calls to `wait` need not have returned).]]
+[[Effects:] [Destroys the object.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:set `void set()`]
+
+ void set();
+
+[variablelist
+[[Effects:] [If any fibers are currently __blocked__ waiting on `*this` in a call
+to `wait`, unblocks those fibers. The variable remains signaled until `this->reset()`
+gets called.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:reset `void reset()`]
+
+ void reset();
+
+[variablelist
+[[Effects:] [The event variable gets nonsignaled and fibers calling `this->wait()`
+will block.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:wait `void wait()`]
+
+ void wait();
+
+[variablelist
+[[Effects:] [Blocks the current fiber. The fiber will unblock when notified by a call
+to `this->set()`. When the fiber is unblocked, the variable remains set.]]
+[[Throws:] [__fiber_interrupted__ if the wait was interrupted by a call to
+__interrupt__ on the __fiber__ object associated with the current fiber of execution.]]
+]
+[endsect]
+
+[section:trywait `boo try_wait()`]
+
+ bool try_wait();
+
+[variablelist
+[[Effects:] [Returns `true` if the event variable is set otherwise `false`.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[endsect]
+
+
+[section:count_down_event Class `count_down_event`]
+
+ #include <boost/fiber/spin/count_down_event.hpp>
+
+ class count_down_event : private boost::noncopyable
+ {
+ public:
+ explicit count_down_event( uint32_t);
+
+ ~count_down_event();
+
+ uint32_t initial() const;
+
+ uint32_t current() const;
+
+ bool is_set() const;
+
+ void set();
+
+ void wait();
+ };
+
+[section:constructor `count_down_event( uint32_t)`]
+
+ explicit count_down_event( uint32_t initial);
+
+[variablelist
+[[Effects:] [Constructs an object of class `count_down_event` with initial value.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:destructor `~count_down_event()`]
+
+ ~count_down_event();
+
+[variablelist
+[[Precondition:] [All fibers waiting on `*this` have been notified by a call to
+`set` (though the respective calls to `wait` need not have returned).]]
+[[Effects:] [Destroys the object.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:initial `uint32_t initial()`]
+
+ uint32_t initial();
+
+[variablelist
+[[Effects:] [Returns the initial value the event variable was initialized with.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:current `uint32_t current()`]
+
+ uint32_t current();
+
+[variablelist
+[[Effects:] [Returns the value the variable currently holds.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:is_set `bool is_set()`]
+
+ bool is_set();
+
+[variablelist
+[[Effects:] [Returns `true` if the varaible has reached zero.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:set `void set()`]
+
+ void set();
+
+[variablelist
+[[Effects:] [Decrements the current count. If the count reaches zero and any fibers are
+currently __blocked__ waiting on `*this` in a call to `wait`, unblocks those fibers.
+The variable remains signaled.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:wait `void wait()`]
+
+ void wait();
+
+[variablelist
+[[Effects:] [Blocks the current fiber. The fiber will unblock when notified by a call
+to `this->set()` and the count of the event variable reaches zero. When the fiber is
+unblocked, the variable remains set.]]
+[[Throws:] [__fiber_interrupted__ if the wait was interrupted by a call to
+__interrupt__ on the __fiber__ object associated with the current fiber of execution.]]
+]
+[endsect]
+
+[endsect]
+
+[endsect]

Added: sandbox/fiber/libs/fiber/doc/spin_fifos.qbk
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/doc/spin_fifos.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -0,0 +1,222 @@
+[/
+ 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
+]
+
+[section:fifos (Un)Bounded fifos using spinwait]
+
+__boost_fiber__ provides a bounded and a unbounded fifo suitable to synchonize fibers via message passing.
+
+[note fifos are [*not] bound to a __scheduler__ an can be used to synchronize fibers
+managed by different schedulers.]
+
+ typedef boost::fibers::unbounded_fifo< int > fifo_t;
+
+ void send( fifo_t fifo)
+ {
+ for ( int i = 0; i < 5; ++i)
+ fifo.put( i);
+ fifo.deactivate();
+ }
+
+ void recv( fifo_t fifo)
+ {
+ boost::optional< int > value;
+ while ( fifo.take( value) )
+ { std::cout << "received " << * value << std::endl; }
+ }
+
+ fifo_t fifo;
+ sched.make_fiber( send, fifo);
+ sched.make_fiber( recv, fifo);
+
+ for (;;)
+ {
+ while ( sched.run() );
+ if ( sched.empty() ) break;
+ }
+
+
+[section:unbounded_fifo Template `template< typename T > unbounded_fifo`]
+
+ #include <boost/fiber/spin/unbounded_fifo.hpp>
+
+ template< typename T >
+ class unbounded_fifo : private noncopyable
+ {
+ public:
+ unbounded_fifo();
+
+ void deactivate();
+
+ bool empty();
+
+ void put( T const& t);
+
+ bool take( boost::optional< T > & va);
+
+ bool try_take( boost::optional< T > & va);
+ };
+
+[section:constructor `unbounded_fifo()`]
+
+ unbounded_fifo();
+
+[variablelist
+[[Effects:] [Constructs an object of class `unbounded_fifo`.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:deactivate `void deactivate()`]
+
+ void deactivate();
+
+[variablelist
+[[Effects:] [Deactivates the fifo. No values can be put after calling `this->deactivate`. Fibers blocked in
+`this->take()` will be return.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:empty `bool empty()`]
+
+ bool empty();
+
+[variablelist
+[[Effects:] [Returns `true` if the fifo currently contains no data.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:put `void put( T const& t)`]
+
+ void put( T const& t);
+
+[variablelist
+[[Effects:] [Enqueues the value in the fifo and wakes up a fiber waiting for new data available from the
+fifo.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:take `bool take( boost::optional< T > & va)`]
+
+ bool take( boost::optional< T > & va);
+
+[variablelist
+[[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the fiber gets suspended until
+new data are enqueued (return value `true` and va contains dequeued value) or the fifo gets deactiveted and
+the function returns `false`.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:try_take `bool try_take( boost::optional< T > & va)`]
+
+ bool try_take( boost::optional< T > & va);
+
+[variablelist
+[[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the function returns `false`.
+Otherwise it returns `true` and `va` contains the dequed value.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[endsect]
+
+
+[section:bounded_fifo Template `template< typename T > bounded_fifo`]
+
+ #include <boost/fiber/spin/bounded_fifo.hpp>
+
+ template< typename T >
+ class bounded_fifo : private noncopyable
+ {
+ public:
+ bounded_fifo( std::size_t wm);
+
+ bounded_fifo( std::size_t hwm, std::size_t lwm);
+
+ void deactivate();
+
+ bool empty();
+
+ void put( T const& t);
+
+ bool take( boost::optional< T > & va);
+
+ bool try_take( boost::optional< T > & va);
+ };
+
+[section:constructor `bounded_fifo()`]
+
+ bounded_fifo( std::size_t wm);
+
+[variablelist
+[[Effects:] [Constructs an object of class `bounded_fifo` which will contain a maximum of `wm` items.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:deactivate `void deactivate()`]
+
+ void deactivate();
+
+[variablelist
+[[Effects:] [Deactivates the fifo. No values can be put after calling `this->deactivate`. Fibers blocked in
+`this->take()` will be return.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:empty `bool empty()`]
+
+ bool empty();
+
+[variablelist
+[[Effects:] [Returns `true` if the fifo currently contains no data.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:put `void put( T const& t)`]
+
+ void put( T const& t);
+
+[variablelist
+[[Effects:] [Enqueues the value in the fifo and wakes up a fiber waiting for new data available from the
+fifo. If the watermark has reached the fiber putting the value will be supended until at least one item
+was dequeued.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:take `bool take( boost::optional< T > & va)`]
+
+ bool take( boost::optional< T > & va);
+
+[variablelist
+[[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the fiber gets suspended until
+new data are enqueued (return value `true` and va contains dequeued value) or the fifo gets deactiveted and
+the function returns `false`.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[section:try_take `bool try_take( boost::optional< T > & va)`]
+
+ bool try_take( boost::optional< T > & va);
+
+[variablelist
+[[Effects:] [Dequeues a value from the fifo. If no data is available from the fifo the function returns `false`.
+Otherwise it returns `true` and `va` contains the dequed value.]]
+[[Throws:] [Nothing.]]
+]
+[endsect]
+
+[endsect]
+
+[endsect]

Added: sandbox/fiber/libs/fiber/doc/spin_mutexes.qbk
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/doc/spin_mutexes.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -0,0 +1,36 @@
+[/
+ (C) Copyright 2007-8 Anthony Williams.
+ 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).
+]
+
+[section:mutex_types Mutex Types using spinwait]
+
+[section:mutex Class `mutex`]
+
+ #include <boost/fibers/spin/mutex.hpp>
+
+ class mutex : private boost::noncopyable
+ {
+ public:
+ mutex();
+ ~mutex();
+
+ void lock();
+ bool try_lock();
+ void unlock();
+
+ typedef unique_lock<mutex> scoped_lock;
+ };
+
+__mutex__ implements the __lockable_concept__ to provide an exclusive-ownership mutex. At most one fiber can own the
+lock on a given instance of __mutex__ at any time. Multiple concurrent calls to __lock_ref__, __try_lock_ref__ and
+__unlock_ref__ shall be permitted.
+
+[note __mutex__ is [*not] bound to a __scheduler__ and can be used to synchronize fibers
+managed by different schedulers.]
+
+[endsect]
+
+[endsect]

Added: sandbox/fiber/libs/fiber/doc/spin_synchronization.qbk
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/doc/spin_synchronization.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -0,0 +1,14 @@
+[/
+ 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
+]
+
+[section:spin_synchronization Synchronization using spinwait]
+[include spin_mutexes.qbk]
+[include spin_condition_variables.qbk]
+[include spin_barrier.qbk]
+[include spin_event_variables.qbk]
+[include spin_fifos.qbk]
+[endsect]

Added: sandbox/fiber/libs/fiber/doc/synchronization.qbk
==============================================================================
--- (empty file)
+++ sandbox/fiber/libs/fiber/doc/synchronization.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -0,0 +1,14 @@
+[/
+ 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
+]
+
+[section:synchronization Synchronization]
+[include mutexes.qbk]
+[include condition_variables.qbk]
+[include barrier.qbk]
+[include event_variables.qbk]
+[include fifos.qbk]
+[endsect]

Modified: sandbox/fiber/libs/fiber/doc/todo.qbk
==============================================================================
--- sandbox/fiber/libs/fiber/doc/todo.qbk (original)
+++ sandbox/fiber/libs/fiber/doc/todo.qbk 2009-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -7,12 +7,12 @@
 
 [section:todo Todo]
 
-* provide an scheduler which deals with priorities
-
-* improve implementation of atomic-ops
-
 * replace system calls related to fiber switching (like swapcontext()) by assembler
 
 * replace thread_specific_ptr by an specialiced implementation for fiber (interusive_ptr)
 
+* provide an scheduler which deals with priorities
+
+* replace implementation of atomic-ops by boost.atomic
+
 [endsect]

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-12-17 17:17:48 EST (Thu, 17 Dec 2009)
@@ -63,7 +63,7 @@
         if ( i == fibers_.end() ) return;
         schedulable s( i->second);
         fiber f( s.f);
- BOOST_ASSERT( f);
+ if ( ! f) return;
         BOOST_ASSERT( ! is_master( f) );
         BOOST_ASSERT( ! in_state_not_started( f) );
 
@@ -406,26 +406,30 @@
         if ( ! runnable_fibers_.empty() )
         {
                 schedulable s = fibers_[runnable_fibers_.front()];
+ runnable_fibers_.pop_front();
                 std::auto_ptr< fiber > orig( active_fiber.release() );
                 active_fiber.reset( new fiber( s.f) );
                 BOOST_ASSERT( ! s.waiting_on_fiber);
+ BOOST_ASSERT( ! s.waiting_on_object);
                 BOOST_ASSERT( in_state_ready( ( * active_fiber) ) );
                 set_state_running( ( * active_fiber) );
                 switch_between( master_fiber, * active_fiber);
                 active_fiber.reset( orig.release() );
- runnable_fibers_.pop_front();
                 result = true;
         }
 
         while ( ! terminated_fibers_.empty() )
         {
- schedulable s = fibers_[terminated_fibers_.front()];
+ fiber_map::iterator i( fibers_.find( terminated_fibers_.front() ) );
+ BOOST_ASSERT( i != fibers_.end() );
+ schedulable s( i->second);
                 fiber f( s.f);
                 terminated_fibers_.pop();
                 BOOST_ASSERT( s.joining_fibers.empty() );
+ BOOST_ASSERT( ! s.waiting_on_fiber);
+ BOOST_ASSERT( ! s.waiting_on_object);
                 BOOST_ASSERT( in_state_terminated( f) );
- fibers_.erase( f.get_id() );
- result = true;
+ fibers_.erase( i);
         }
         return result;
 }


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