2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-12 12:02:54 +00:00
Commit Graph

10 Commits

Author SHA1 Message Date
Nat Goodspeed
402a4353f7 Define sched_algorithm methods on fiber_base*, not worker_fiber*.
Some reviewers disliked that to build a custom sched_algorithm subclass, you
must necessarily manipulate pointers to classes in the boost::fibers::detail
namespace. Redefine all such methods to use fiber_base* rather than
detail::worker_fiber*.

Hoist fiber_base* into boost::fibers namespace. We considered an opaque
typedef rather than fiber_base*, but in fact a sched_algorithm subclass may
need is_ready().

Moreover, a sched_algorithm subclass may well want to use an intrusive linked
list to queue fibers. Hoist worker_fiber::nxt_ pointer into fiber_base, and
remove worker_fiber::next() and next_reset() methods. This allows recasting
detail::fifo in terms of fiber_base*, therefore round_robin can be stated
almost entirely in terms of fiber_base* rather than worker_fiber*.

Recast fiber constructor taking worker_fiber* to take fiber_base* instead.
This constructor is used solely for fiber migration; with relevant functions
now returning fiber_base*, we think we no longer need fiber(worker_fiber*).
2014-11-10 21:19:28 -05:00
Nat Goodspeed
3128334364 Initial cut at supporting arbitrary user-coded scheduler properties.
Introduce fiber_properties class from which to derive a specific properties
class for a particular user-coded sched_algorithm subclass.

Add sched_algorithm::property_change(worker_fiber*, fiber_properties*) method
to allow a fiber_properties subclass method to notify the sched_algorithm
subclass of a change in a relevant property. This generalizes the present
priority() method.

Introduce sched_algorithm_with_properties<PROPS> template class from which to
derive a user-coded scheduler that uses fiber_properties subclass PROPS. Give
it ref-returning properties(fiber::id) and properties(worker_fiber*) methods.

Introduce fiber_properties* field in worker_fiber, and initialize it to 0.
Delete it when the worker_fiber is destroyed. Give it pointer-flavored access
methods. Normally this field will remain 0; but the first time the
worker_fiber is passed to a sched_algorithm_with_properties<PROPS> subclass,
its awakened() method will instantiate the relevant PROPS subclass.

Add ref-returning fiber::properties<PROPS>() method. Calling this method
presumes that the current thread's sched_algorithm is derived from
sched_algorithm_with_properties<PROPS>.

Also add this_fiber::properties<PROPS>() with the same restriction.

Add ref-returning fm_properties<PROPS>() functions to implement
fiber::properties<PROPS>() and this_fiber::properties<PROPS>().

Allow sched_algorithm_with_properties to extract the worker_fiber* from a
fiber::id (aka worker_fiber::id) so it can present public-facing
properties(id) method as well as properties(worker_fiber*) method.
(cherry picked from commit 18c7f2c13b9642826b42aa3f6fa0a6642fce9cbc)

Conflicts:
	include/boost/fiber/detail/worker_fiber.hpp
	include/boost/fiber/fiber_manager.hpp
2014-11-08 11:03:51 -05:00
Oliver Kowalke
ae1ebd7b01 Revert "optimize the example for asio loop"
This reverts commit 61a8a8ea89.
2014-09-18 19:25:58 +02:00
Vincent Lee
61a8a8ea89 optimize the example for asio loop 2014-09-15 18:14:15 +08:00
Oliver Kowalke
c005bb2c8f doc update 2014-09-09 20:40:26 +02:00
Oliver Kowalke
0948d577dc fix examples 2014-08-23 14:09:21 +02:00
Oliver Kowalke
4b604ff93a test for multiple definitions 2014-08-21 17:28:28 +02:00
Oliver Kowalke
e24f27c75c fix publish-subscriber example 2014-08-21 17:27:53 +02:00
Oliver Kowalke
ef6c16e934 optimized server app in publish-subscribe example 2014-08-17 20:41:31 +02:00
Oliver Kowalke
22850775ca variadric tempalte args 2014-07-15 20:33:14 +02:00