mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-12 12:02:54 +00:00
Merge branch 'develop' of github.com:olk/boost-fiber into develop
This commit is contained in:
@@ -684,8 +684,8 @@ there are no guarantees about how soon after that it might resume.]]
|
||||
[variablelist
|
||||
[[Effects:] [Reliquishes execution control, allowing other fibers to run.]]
|
||||
[[Throws:] [__fiber_resource_error__ if an error occurs.]]
|
||||
[[Note:] [`yield()` is ['not] an interruption point. A fiber that calls
|
||||
`yield()` is not suspended: it is immediately passed to the scheduler as ready
|
||||
[[Note:] [`yield()` is a interruption point. A fiber that calls
|
||||
`yield()` is suspended, but it is immediately passed to the scheduler as ready
|
||||
to run.]]
|
||||
]
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ run (context switching).
|
||||
__boost_fiber__ internally uses __econtext__ from __boost_context__; the classes in
|
||||
this library manage, schedule and, when needed, synchronize those execution contexts.
|
||||
A context switch between threads usually costs thousands of CPU cycles on x86,
|
||||
compared to a fiber switch with a few hundred cycles.
|
||||
compared to a fiber switch with less than hundred cycles.
|
||||
A fiber can only run on a single thread at any point in time.
|
||||
|
||||
In order to use the classes and functions described here, you can either include
|
||||
@@ -68,10 +68,10 @@ A fiber launched on a particular thread will always run on that thread. A
|
||||
fiber can count on thread-local storage; however that storage will be shared
|
||||
among all fibers running on the same thread.
|
||||
|
||||
The fiber synchronization objects provided by this library will not, by
|
||||
default, safely synchronize fibers running on different threads. However, they
|
||||
can be coerced to provide that safety by building the library with
|
||||
`BOOST_FIBERS_THREADSAFE` defined. Please see [link synchronization].
|
||||
The fiber synchronization objects provided by this library will, by default,
|
||||
safely synchronize fibers running on different threads. However, they safety can
|
||||
be removed (for performance) by building the library with
|
||||
BOOST_FIBERS_NO_ATOMICS defined. Please see [link synchronization].
|
||||
|
||||
For fiber-local storage, please see __fsp__.
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ customization point. (See [link custom].)
|
||||
Each thread has its own scheduler. By default, __boost_fiber__ implicitly
|
||||
instantiates [class_link round_robin] as the scheduler for each thread.
|
||||
|
||||
To prevent the library from heap-allocating the default scheduler for a given
|
||||
thread, that thread must call [function_link set_scheduling_algorithm] before
|
||||
any other __boost_fiber__ entry point.
|
||||
|
||||
You are explicitly permitted to code your own __algo__ subclass, and to pass
|
||||
it to [function_link set_scheduling_algorithm].
|
||||
|
||||
@@ -45,8 +41,7 @@ fiber scheduler must implement.
|
||||
|
||||
#include <boost/fiber/algorithm.hpp>
|
||||
|
||||
struct sched_algorithm
|
||||
{
|
||||
struct sched_algorithm {
|
||||
virtual ~sched_algorithm() {}
|
||||
|
||||
virtual void awakened( fiber_context *) = 0;
|
||||
@@ -88,7 +83,7 @@ queue.]]
|
||||
virtual std::size_t ready_fibers() const noexcept = 0;
|
||||
|
||||
[variablelist
|
||||
[[Effects:] [Returns 0 if scheduling algorithm has fibers ready to run,
|
||||
[[Effects:] [Returns 0 if scheduling algorithm has no fibers ready to run,
|
||||
otherwise nonzero.]]
|
||||
]
|
||||
|
||||
@@ -99,8 +94,7 @@ This class implements __algo__, scheduling fibers in round-robin fashion.
|
||||
|
||||
#include <boost/fiber/round_robin.hpp>
|
||||
|
||||
class round_robin: public sched_algorithm
|
||||
{
|
||||
class round_robin: public sched_algorithm {
|
||||
virtual void awakened( fiber_context *);
|
||||
|
||||
virtual fiber_context * pick_next();
|
||||
@@ -143,10 +137,9 @@ A custom fiber properties class must be derived from `fiber_properties`.
|
||||
|
||||
#include <boost/fiber/properties.hpp>
|
||||
|
||||
class fiber_properties
|
||||
{
|
||||
class fiber_properties {
|
||||
public:
|
||||
fiber_properties( back_ptr f );
|
||||
fiber_properties( back_ptr f);
|
||||
|
||||
virtual ~fiber_properties() {}
|
||||
|
||||
@@ -156,7 +149,7 @@ A custom fiber properties class must be derived from `fiber_properties`.
|
||||
|
||||
[heading Constructor]
|
||||
|
||||
fiber_properties( back_ptr f );
|
||||
fiber_properties( back_ptr f);
|
||||
|
||||
[variablelist
|
||||
[[Effects:] [Constructs base-class component of custom subclass.]]
|
||||
@@ -198,10 +191,9 @@ derived from [class_link fiber_properties].
|
||||
#include <boost/fiber/algorithm.hpp>
|
||||
|
||||
template< typename PROPS >
|
||||
struct sched_algorithm_with_properties
|
||||
{
|
||||
struct sched_algorithm_with_properties {
|
||||
// override this method instead of sched_algorithm::awakened()
|
||||
virtual void awakened( fiber_context * f, PROPS& properties ) = 0;
|
||||
virtual void awakened( fiber_context * f, PROPS & properties) = 0;
|
||||
|
||||
virtual fiber_context * pick_next();
|
||||
|
||||
@@ -219,7 +211,7 @@ derived from [class_link fiber_properties].
|
||||
|
||||
[member_heading sched_algorithm_with_properties..awakened]
|
||||
|
||||
virtual void awakened( fiber_context * f, PROPS& properties );
|
||||
virtual void awakened( fiber_context * f, PROPS & properties);
|
||||
|
||||
[variablelist
|
||||
[[Effects:] [Informs the scheduler that fiber `f` is ready to run, like
|
||||
@@ -290,10 +282,8 @@ implementations of [class_link fiber] methods.)
|
||||
|
||||
#include <boost/fiber/fiber_context.hpp>
|
||||
|
||||
class fiber_context
|
||||
{
|
||||
class fiber_context {
|
||||
public:
|
||||
|
||||
fiber_context * nxt;
|
||||
|
||||
static fiber_context * main_fiber();
|
||||
|
||||
Reference in New Issue
Block a user