2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-01-24 05:52:09 +00:00
Commit Graph

61 Commits

Author SHA1 Message Date
Dmitry Khominich
f1ab9c738e introduce waker and wait_queue abstractions. fixes #251, #259
* remove context::wait_hook_ and context::twstatus in flavor to waker_epoch_ and waker class
* this avoids data races in case of wait_until() operations, when the context
  could be timeouted and rescheduled on the other OS thread. In this case could
  be data races with context::wait_hook_ and inconsistences context::twstatus
  states.
* using context::waker_epoch_ introduces mechanism when the old wakers become
  outdated and waker::wake() is just no op. This fixes data races explained in
  the previous point
* fibers waiting queue with timeouts and notification mechanisms are incapsulated into
  wait_queue class. This introduces simple abstraction level to be used in
  different synchronization primitives
2020-10-14 17:15:07 +03:00
Oliver Kowalke
1490ec4586 Merge branch 'develop' into nb 2020-01-13 08:10:06 +01:00
Rosen Penev
ce1093bf83 treewide: Use auto where appropriate
Found with clang-tidy's modernize-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-01-12 16:10:26 -08:00
Rosen Penev
3880c03f5e treewide: Do not use else after return or throw
Found with clang-tidy's readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-01-07 21:07:54 -08:00
Oliver Kowalke
53eddf651f remove use-coutner increment for timed wait ops.
- in context of #162
2017-12-27 09:49:41 +01:00
Oliver Kowalke
23b82d5610 fix race related to timed-wait operations
- applies to:
    * condition_varxpaible
    * buffered_channel
    * unbuffered_channel
    * timed_mutex
    * recursive_timed_mutex
    * this_fiber::sleep_for()
    * this_fiber::sleep_until()
- if a context does a timed-wait on an primitive a race
  between timeout- and notification-event might happen
- the timeout-event is triggered by the dispatcher-context
  of the scheduler the waiting context belongs to (worker-context)
- the notification-event might be triggered by another thread
- if the nofification happens before timeout, the dispatcher-context
  needs to know this in order not the re-schedule the context (might
  already be in the ready-queue or already terminated or moved to
  another scheduler/thread)
- if the timeout happens before the notification, the notification
  routine must not re-schedule the context
- some primitives provide timed and non-timed wait-operations,
  this must be detected by dispatcher-context and notification routine

-> each timed-wait op. increments the use-counter of the context in
   order to prevent dereferencing an already termianted and thus
   deallocated context
-> each context maintains an timed-wait-status member variable
   'twstatus'
-> 'twstatus' is atomic; allowed values:
    * twstatus == 0: non-timed wait op.
    * twstatus == <address>: timed wait op., value eq. the address of
      the primitive were the timed-wait op. is applied
    * twstatus == -1: timed-wait op., context has been already resumed
      by other notification-event or timeout-event
2017-06-17 11:13:07 +02:00
Oliver Kowalke
732e91b634 Revert "no data transferred via continuation::resume()"
This reverts commit 953bcb423e.
2017-06-10 16:33:01 +02:00
Oliver Kowalke
c8f6ddc497 use conditional expression likely/unlikely 2017-06-08 23:22:09 +02:00
Oliver Kowalke
116419ccb4 mutex: loop and test in lock() 2017-06-05 16:49:43 +02:00
Oliver Kowalke
953bcb423e no data transferred via continuation::resume()
- transfer from-context, ready-context, spinlock_lock via context
2017-05-29 18:13:08 +02:00
Oliver Kowalke
547d64d45f use single-linked instead of double-linked instrusive list 2017-03-27 18:05:55 +02:00
Oliver Kowalke
8c6f853201 Revert "use wait-queue based on array"
This reverts commit ecb87f2945.
2017-03-17 19:57:48 +01:00
Oliver Kowalke
ecb87f2945 use wait-queue based on array 2017-03-17 17:52:44 +01:00
Oliver Kowalke
728bd776ad rename set_ready() -> schedule() 2017-03-05 15:08:52 +01:00
Oliver Kowalke
fa95e9740f code re-formating 2017-02-26 20:22:58 +01:00
Oliver Kowalke
24fa47a1f0 remove noexcept from mutex/timed_mutex try_lock() 2015-12-29 11:57:25 +01:00
Oliver Kowalke
056a681459 fix fiber-exceptions 2015-12-26 19:52:21 +01:00
Oliver Kowalke
3319841788 use spinlock_lock+context instead of function<> 2015-12-03 17:57:00 +01:00
Oliver Kowalke
726d4d51b9 ++14 polishing 2015-12-01 21:07:11 +01:00
Oliver Kowalke
bafd65bcf3 remove yield-queue + pass functor to resume-op 2015-10-16 21:48:57 +02:00
Oliver Kowalke
a847baa932 link/unlink of context protected by spinlock 2015-09-28 19:58:22 +02:00
Oliver Kowalke
2e0d09b3c7 fix comparation of address and nullptr 2015-09-21 20:14:07 +02:00
Oliver Kowalke
22a1f1257d some source code formating 2015-09-20 15:38:43 +02:00
Oliver Kowalke
6b01f060b7 class timed_mutex added 2015-09-19 18:03:41 +02:00
Oliver Kowalke
6d43540a29 cleanup 2015-09-15 19:15:00 +02:00
Oliver Kowalke
abd1ff524c fixes for signaling interruption and wait 2015-09-11 18:42:16 +02:00
Oliver Kowalke
4764c1184c signal() added 2015-09-10 19:52:08 +02:00
Oliver Kowalke
d3843efbe0 fix using intruisve::list<> 2015-09-10 18:08:10 +02:00
Oliver Kowalke
c1d3d478d8 use wait_queue with safe_link featurre, use erase_and_dispose() for
unlinking
2015-09-10 05:49:10 +02:00
Oliver Kowalke
c89410dfd8 uses intrusive::list<> isntread hand-written queues 2015-09-09 19:22:54 +02:00
Oliver Kowalke
d66575e2e6 fiber_manager renamed to scheduler 2015-09-07 17:35:37 +02:00
Oliver Kowalke
6499bb07e7 fiber_context renamed to context 2015-09-07 17:23:59 +02:00
Oliver Kowalke
7233f617d7 remove class scheduler - fiber_context has static TLS
- detail:.scheduler was removed
- fiber_context has a static thread-local pointer to the active
  fiber_context
- fiber_context has member to pointer of fiber_manager
- functions of fiber_manager are accessed only via fiber_context
- if fiber f is resumed, the fiber_manager of the current active fiber
  f' is assigned to f
  -> that is necessary if f was stolen form another thread
2015-09-07 11:50:01 +02:00
Oliver Kowalke
66e7b59424 fix usage of std::chrono 2015-09-05 11:57:36 +02:00
Oliver Kowalke
0a296315f7 use steady_clock isntead of high_resolution_clock 2015-09-05 10:57:50 +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
aa337b07f7 move 'fm_' - free functions into fiber_manager 2015-02-08 16:02:22 +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
2f19be6d67 use C++11 2014-12-27 19:07:42 +01: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
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
91ccc91ee7 some fixes 2014-06-22 19:31:58 +02:00
Oliver Kowalke
026003bb65 use the free fm_<xyz> - functions 2014-06-17 11:51:14 +02:00
Oliver Kowalke
2d012334b1 allocate main_fiber inside synch. primitives 2014-03-22 18:22:32 +01:00
Oliver Kowalke
228aae6833 do not use reference-counting 2014-03-19 19:55:56 +01:00