* 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
- 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
- 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