Commit Graph

1840 Commits

Author SHA1 Message Date
Nat Goodspeed
3cb5b2a341 Remove thread_affinity flag and access methods.
Specificaly, remove access methods in worker_fiber, fiber and this_fiber.

thread_affinity is not used by any present library code. It was intended for
use by workstealing user sched_algorithm implementations. The properties
mechanism is a better way to address scheduler-specific properties.
2014-11-11 09:53:25 -05:00
Nat Goodspeed
84c2c6abad Make unbounded_queue::tail_ a ptr* to simplify linking new nodes. 2014-11-11 08:56:06 -05:00
Nat Goodspeed
3cb43d6b9d Make bounded_queue::tail_ a ptr* to simplify appending new nodes. 2014-11-11 08:49:46 -05:00
Nat Goodspeed
20a2f59913 Reimplement waiting_queue::move_to() using fiber_base** scan.
This simplifies unlinking from the queue.
2014-11-11 08:38:34 -05:00
Nat Goodspeed
2bffbddeaa Reimplement waiting_queue::push() using pointer-to-pointer trick.
Change waiting_queue::head_ from worker_fiber* to fiber_base* for uniformity
with worker_fiber::nxt_. This lets push() scan from head_ with a fiber_base**,
looking for the right insertion point. Insertion then becomes a couple
unconditional assignments.

Because push() always scans from head_, tail_ was actually never used. Remove
it.
2014-11-11 07:42:56 -05:00
Nat Goodspeed
12fe326c6f Simplify detail::fifo by making tail_ point to last link pointer.
Maintaining a singly-linked list is tricky when you walk it with a node*
pointer. But if you use a node** pointer starting at &head_ and advancing to
point to each &nxt_ pointer, you can coalesce the empty-list case into the
normal case.
2014-11-11 07:26:45 -05:00
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
ed64ee77f8 Set fiber_properties::sched_algo_ every time through awakened().
Instead of setting a fiber_properties subclass's sched_algo_ back pointer once
at construction time, unconditionally set it every time that fiber becomes
READY (and is therefore passed to sched_algorithm::awakened()). This handles
the case in which that fiber migrates to a different thread with a different
sched_algorithm subclass instance.

Break out fiber_properties::notify() implementation to a separate .cpp
implementation file so it can bring in algorithm.hpp. We don't want
properties.hpp to depend on algorithm.hpp.
2014-11-10 19:59:29 -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
6a1257442b re-factoring of thread_local_ptr<>
Conflicts:
	include/boost/fiber/detail/scheduler.hpp
	src/detail/scheduler.cpp
	src/fiber_manager.cpp
2014-10-01 23:19:36 +02:00
Oliver Kowalke
2e4fa3e53f re-factoring of thread_local_ptr<> 2014-10-01 21:40:12 +02:00
Oliver Kowalke
1c3b447716 some fixes 2014-09-26 17:57:53 +02:00
Oliver Kowalke
70440591cf call cleanup-function in thread_local_ptr
(cherry picked from commit fca6e0301a)
2014-09-25 19:06:01 +02:00
Oliver Kowalke
b0eb8bc592 call cleanup-function in thread_local_ptr
(cherry picked from commit fca6e0301a)
2014-09-25 18:59:10 +02:00
Oliver Kowalke
7483a729aa some fixes 2014-09-25 18:52:04 +02:00
Oliver Kowalke
fca6e0301a call cleanup-function in thread_local_ptr 2014-09-25 18:51:30 +02:00
Oliver Kowalke
7fb469cd10 some fixes 2014-09-24 19:18:44 +02:00
Oliver Kowalke
244c539a2e Add some explanatory material in scheduling.qbk about coding your own
scheduler and setting it with set_scheduling_algorithm(). Document
sched_algorithm interface class.

Fix the example in condition_variables.qbk to explicitly unlock 'lk'
before
calling process_data().
2014-09-22 19:11:22 +02:00
Nat Goodspeed
6fb1b04789 Change some doc references from 'algorithm' to 'sched_algorithm'.
Add some explanatory material in scheduling.qbk about coding your own
scheduler and setting it with set_scheduling_algorithm(). Document
sched_algorithm interface class.

Fix the example in condition_variables.qbk to explicitly unlock 'lk' before
calling process_data().
2014-09-22 10:00:34 -04:00
Oliver Kowalke
a21b18b856 update docu 2014-09-19 16:58:16 +02:00
Oliver Kowalke
5910ac9eff remove 'break' from qaiting_queue
- break prevents asio exmples from working
2014-09-18 20:37:55 +02:00
Oliver Kowalke
ae1ebd7b01 Revert "optimize the example for asio loop"
This reverts commit 61a8a8ea89.
2014-09-18 19:25:58 +02:00
Oliver Kowalke
8dc8dce605 docu update 2014-09-15 17:03:31 +02:00
olk
8b8677d061 Merge pull request #23 from absolute8511/fix-asio-example
optimize the example for asio loop
2014-09-15 16:58:18 +02:00
olk
11d9d6449b Merge pull request #22 from absolute8511/fix-deque-erase
fix deque erase, the end() iterator cannot be used as erase position.
2014-09-15 16:57:12 +02:00
Oliver Kowalke
184455bca4 remove html 2014-09-15 16:56:01 +02:00
Vincent Lee
61a8a8ea89 optimize the example for asio loop 2014-09-15 18:14:15 +08:00
Vincent Lee
c6cdd4a988 fix deque erase, the end() iterator cannot be used as erase position. 2014-09-15 18:04:36 +08:00
Oliver Kowalke
bdab3735ed update docu 2014-09-12 16:58:07 +02:00
Oliver Kowalke
c161e095af docu update 2014-09-09 21:02:12 +02:00
Oliver Kowalke
c005bb2c8f doc update 2014-09-09 20:40:26 +02:00
Oliver Kowalke
ef7eff3d43 update docu 2014-09-07 10:51:33 +02:00
Oliver Kowalke
491012776f update docu 2014-09-05 17:55:49 +02:00
Oliver Kowalke
e48252837f accept any clock type for lock_until() etc. 2014-09-05 17:55:16 +02:00
Oliver Kowalke
2d4a919faa fix errors because of -pedantic 2014-08-23 14:20:01 +02:00
Oliver Kowalke
0948d577dc fix examples 2014-08-23 14:09:21 +02:00
Oliver Kowalke
0aaff7cb6d fix queues::push(9 for MSVC 2014-08-23 13:40:42 +02:00
Oliver Kowalke
6c1229af0d call forward() and move() with namespace boost 2014-08-21 20:22:10 +02:00
Oliver Kowalke
64ea436557 inline functions for full-specialized tempaltes 2014-08-21 17:34:23 +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
32d4a056d0 update documentation 2014-08-20 17:37:47 +02:00
Oliver Kowalke
00944ddf6a update using chrono-clocks 2014-08-20 17:37:47 +02:00
olk
539660d132 Merge pull request #19 from niXman/develop
preprocessor inline macro replaced
2014-08-17 22:04:54 +02:00
niXman
13bbaf0ced preprocessor inline macro replaced 2014-08-17 22:56:42 +03:00
Oliver Kowalke
ef6c16e934 optimized server app in publish-subscribe example 2014-08-17 20:41:31 +02:00
Oliver Kowalke
5ede204812 optimize calling high_resolution_clock::now() 2014-08-17 20:28:40 +02:00
Oliver Kowalke
ccbda7c04a improve performance tests and docu 2014-07-31 18:04:25 +02:00
Oliver Kowalke
cffd471abb update performance tests 2014-07-30 17:59:44 +02:00
Oliver Kowalke
f615b5f6fc fix bind() using variadric args 2014-07-29 18:13:39 +02:00