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

237 Commits

Author SHA1 Message Date
Oliver Kowalke
4140e10330 this_fiber::yield() is not an interruption point 2015-07-29 11:47:17 +02:00
Oliver Kowalke
642fff9b93 remove unused preserve_fpu() functionality 2015-07-29 11:14:27 +02:00
Oliver Kowalke
d61b395207 Update round_robin.cpp 2015-07-20 19:42:11 +02:00
Oliver Kowalke
e7b1ee131c add function ready_fibers() 2015-07-03 18:03:14 +02:00
Oliver Kowalke
5d18cd5a4e add interruption point after fiber_manager::run()
- functions fiber_manager::join()/fiber_manager::yield()/fiber_manager:.wait()/fiber_manager_wait_until()
  check for interrption of the current fiber
2015-06-21 10:53:37 +02:00
Oliver Kowalke
6c35324727 use atomics per default
- atomics can be disable using BOOST_FIBERS_NO_ATOMICS compiler flag
2015-06-20 21:31:34 +02:00
Oliver Kowalke
20d08d98cd enable atomics with BOOST_FIBERS_USE_ATOMCIS 2015-06-19 21:39:34 +02:00
Oliver Kowalke
2002dba9d3 enable/disable atomic<> with BOOST_FIBERS_THREADSAFE 2015-06-19 18:57:23 +02:00
Oliver Kowalke
61dc492f31 some stuff/corrections 2015-06-19 18:55:02 +02:00
Oliver Kowalke
52a9da9180 remove invalid noexcept specifier from fiber::detach() 2015-06-13 08:40:13 +02:00
Oliver Kowalke
e2404eefd7 introduce new queue for terminated fibers 2015-06-13 08:14:14 +02:00
Oliver Kowalke
e22c7fb1cb some formating 2015-05-22 09:50:39 +02:00
Nat Goodspeed
dadc42a028 Add missing #include fiber_context.hpp. 2015-05-13 08:45:01 -04:00
Nat Goodspeed
f66cc3389d Remove static fm_mumble() functions brought over during merge.
Specifically, remove fm_get_sched_algo_() and two fm_wait_interval()
overloads.
2015-05-13 08:44:14 -04:00
Nat Goodspeed
04be1f0f84 algorithm.hpp no longer lives in detail subdirectory. 2015-05-13 08:41:38 -04:00
Nat Goodspeed
a4e77e502f Re-add bool fiber_manager::preserve_fpu() to header file. 2015-05-11 05:46:26 -04:00
Nat Goodspeed
765014daee working our way through build errors 2015-05-11 05:38:45 -04:00
Nat Goodspeed
9c4cdf3438 Desk-checking pass through fiber_properties source code. 2015-05-10 23:35:15 -04:00
Nat Goodspeed
2687814477 Merge branch 'develop' of github.com:olk/boost-fiber into sched-props-dev
Resolved conflicts:
	doc/condition_variables.qbk
	examples/cpp03/migration/workstealing_round_robin.cpp
	examples/cpp03/migration/workstealing_round_robin.hpp
	include/boost/fiber/algorithm.hpp
	include/boost/fiber/bounded_queue.hpp
	include/boost/fiber/detail/fiber_base.hpp
	include/boost/fiber/detail/fifo.hpp
	include/boost/fiber/detail/waiting_queue.hpp
	include/boost/fiber/detail/worker_fiber.hpp
	include/boost/fiber/fiber.hpp
	include/boost/fiber/fiber_manager.hpp
	include/boost/fiber/fixedsize_stack.hpp
	include/boost/fiber/operations.hpp
	include/boost/fiber/round_robin.hpp
	include/boost/fiber/unbounded_queue.hpp
	src/detail/worker_fiber.cpp
	src/fiber.cpp
	src/fiber_manager.cpp
	src/round_robin.cpp
2015-05-10 22:03:35 -04:00
Oliver Kowalke
aa337b07f7 move 'fm_' - free functions into fiber_manager 2015-02-08 16:02:22 +01:00
Oliver Kowalke
13bf486fea update stack-allocators 2015-02-06 18:29:26 +01:00
Oliver Kowalke
f37d7c5511 store terminated fibers in tqueue 2015-01-15 21:22:10 +01:00
Oliver Kowalke
27c0a78d36 allocate fiber_context on stack 2015-01-13 14:57:32 +01:00
Oliver Kowalke
654127af00 rename fiber_base -> fiber_context and move to public namespace 2015-01-04 16:05:08 +01:00
Oliver Kowalke
0fda6d1f88 remove some warnings 2015-01-04 13:13:15 +01:00
Oliver Kowalke
584dcdceee allocate/deallocate fiber_base via allocator 2014-12-29 17:38:01 +01:00
Oliver Kowalke
44326ebdd3 remove priority 2014-12-28 08:35:44 +01:00
Oliver Kowalke
7f7f01098b make main-fiber thread affine 2014-12-27 21:16:03 +01:00
Oliver Kowalke
2f19be6d67 use C++11 2014-12-27 19:07:42 +01:00
Oliver Kowalke
ddbdd91ced use execution_context 2014-11-24 19:58:59 +01:00
Nat Goodspeed
95812f8321 Only notify() a sched_algorithm_with_properties if it is_ready().
While it's true that not every READY fiber is always in the scheduler's ready
queue -- there's a time window in which a READY fiber can be on the
fiber_manager's wait queue -- only READY fibers will ever be on the
scheduler's ready queue. So if (! fiber.is_ready()), there's no point in
bothering the sched_algorithm implementation with a change to its properties.
2014-11-19 10:25:31 -05:00
Nat Goodspeed
3595857849 property_change() method doesn't really belong in sched_algorithm.
sched_algorithm knows nothing about properties, so that class isn't really the
best place for the property_change() virtual method. Introduce intermediate
sched_algorithm_with_properties_base class, which introduces property_change_()
virtual method accepting fiber_properties*. Then the properties-specific
sched_algorithm_with_properties<PROPS> implementation calls property_change()
(no trailing underscore) with fiber_properties* cast to PROPS&. Thus the user-
coded sched_algorithm implementation can override property_change() and accept
PROPS& rather than the generic fiber_properties* pointer. But
fiber_properties::notify() -- which doesn't know its own PROPS subclass -- can
nonetheless call sched_algorithm_with_properties_base::property_change_().
2014-11-14 09:58:48 -05:00
Nat Goodspeed
f1a34d297f Remove 'priority' for every fiber, and its support methods.
Priority is another property that's only relevant for future sched_algorithm
implementations. We don't even have an example yet. It's a good candidate for
moving to a specific fiber_properties subclass for that specific
sched_algorithm implementation.
2014-11-11 18:00:18 -05:00
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
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
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
7483a729aa some fixes 2014-09-25 18:52:04 +02:00
Oliver Kowalke
7fb469cd10 some fixes 2014-09-24 19:18:44 +02: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
c005bb2c8f doc update 2014-09-09 20:40:26 +02:00
Oliver Kowalke
5ede204812 optimize calling high_resolution_clock::now() 2014-08-17 20:28:40 +02:00
Nat Goodspeed
b01cc1f224 Reintroduce pthread_key_create() implementation for Mac thread_local_ptr.
At some point the original implementation seems to have gotten lost?
2014-07-17 15:02:04 -04:00
Oliver Kowalke
22850775ca variadric tempalte args 2014-07-15 20:33:14 +02:00
Oliver Kowalke
8df4a56564 use high_resolution_clock 2014-07-07 20:32:56 +02:00
Oliver Kowalke
05256654da reduce redundancy of try_lock()/lock() in mutex 2014-07-05 11:09:40 +02:00
Oliver Kowalke
b936512136 remove mutex::scoped_lock by unique_lock< mutex > 2014-06-29 13:31:01 +02:00
Oliver Kowalke
a2d3eba716 fix migrating a fiber between threads 2014-06-26 19:01:49 +02:00