2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-19 14:22:23 +00:00
Commit Graph

245 Commits

Author SHA1 Message Date
Nat Goodspeed
cba1a74b70 Eliminate yield_hop_t, therefore yield_base type.
The whole yield / yield_hop dichotomy becomes much easier to read and explain
if we stick to a single yield_t class. Since the intention is for a consumer
to pass canonical instances rather than manipulating that class in any other
way, we can instantiate it however we want.

This gets rid of lots of ugly redundant boost::asio::handler_type<>
specializations.
2016-03-23 21:43:01 -04:00
Nat Goodspeed
85c0d26d11 Fix minor errors in doc generation. 2016-03-23 21:28:40 -04:00
Nat Goodspeed
0645d37fea Merge branch 'develop' of github.com:olk/boost-fiber into develop.
Incorporate Oliver's use of fibers::detail::spinlock, but break out
yield_base, yield_handler_base and async_result_base as before.
2016-03-23 20:27:42 -04:00
oliver Kowalke
ddab318255 wait for uncompleted asio-fiber 2016-03-16 08:51:33 +01:00
Nat Goodspeed
3e7b94c922 Fix silly compile errors in yield.hpp and detail/yield.hpp.
Still to fix: can't use ctx_->set_ready(ctx_) to wake suspended context on its
own scheduler.
2016-03-14 21:20:30 -04:00
Nat Goodspeed
5758781500 Allow caller of asio async function to permit or deny migration.
Introduce yield_base with subclasses yield_t and yield_hop_t, each with a
canonical instance yield and yield_hop. yield_base adds allow_hop_ bool to
communicate the distinction to yield_handler: yield_t sets false, yield_hop_t
sets true.

Extract common base class yield_handler_base from yield_handler<T> and
yield_handler<void>. In fact yield_handler_base is almost identical to
yield_handler<void>; yield_handler<T> adds value processing.

Instead of capturing just the error_code* from the passed yield_base instance,
capture the whole yield_base: both its error_code* and the new allow_hop_ bool.

yield_handler_base provides operator()(error_code) method. This operator()
sets a new completed_ bool so calling fiber need NOT suspend if the async
operation completes immediately. That bool must be defended with a mutex.

This operator() also avoids migrating a pinned_context, or when a caller
passes plain yield instead of yield_hop.

New wait() method suspends the calling fiber only if (! completed_).

Extract common base class async_result_base from async_result<T> and
async_result<void>. In fact async_result_base is almost identical to
async_result<void>; async_result<T> adds value processing.

Add handler_type<> specializations for new yield_base and yield_hop_t
completion token types.
2016-03-13 14:20:46 -04:00
Oliver Kowalke
4a3442e045 apply thread_local keyword to global yield (asio) 2016-03-07 18:47:44 +01:00
oliver Kowalke
ffffd322bb imake asio example thread-safe 2016-03-01 08:56:15 +01:00
Oliver Kowalke
fc73bdfc52 merge examples echo_client+echo_server into one application 2016-02-29 19:00:42 +01:00
Oliver Kowalke
d1430e395b change asio/echo example 2016-02-28 20:24:12 +01:00
Oliver Kowalke
6fb1c627ac fix adatp_callbacks.cpp 2016-02-17 19:48:25 +01:00
Oliver Kowalke
f48cbd6f2f adatp-callbacks: C++11 does not support generalized lambda captures 2016-02-17 17:17:55 +01:00
Oliver Kowalke
b56d95b8fc fix example adapt_callbacks
C++11 does not support generalized lambda captures
2016-02-16 11:06:32 +01:00
Oliver Kowalke
43eb5bd769 fix example priority.cpp 2016-02-16 11:05:21 +01:00
Nat Goodspeed
78e30d8416 Streamline implementation of priority.cpp's priority_scheduler.
Now that rqueue_ is an STL-compatible container,
priority_scheduler::awakened() can use std::find_if() to search for a context
with a lower priority.

Now that rqueue_ is an intrusive_list, priority_scheduler::property_change()
need not search it: it can simply test with context::ready_is_linked(). Now
that it's a doubly-linked list, we can use context::ready_unlink() to unlink.

Now that method parameters have been renamed from 'f' to 'ctx', change all
references in comments accordingly.
2016-02-15 20:27:44 -05:00
Nat Goodspeed
8376fda3ba Merge branch 'develop' of github.com:olk/boost-fiber into develop 2016-02-15 19:34:04 -05:00
Nat Goodspeed
ea0c16080b A few more documentation-related edits 2016-02-15 17:12:56 -05:00
Oliver Kowalke
e43cf5b1ac enum for context types 2016-02-15 19:49:22 +01:00
Nat Goodspeed
87551c5419 Snapshot of ongoing pass through Fiber documentation.
Highlight predicate condition_variable::wait() method in condition_variable
front matter.

Rewrite the explanation of wait()'s Precondition.

Add a condition_variables subsection about no spurious condition_variable
wakeups. Remove "or spuriously" from wakeup conditions in wait*() methods.
First pass through "spurious wakeup" section in Rationale.

First pass through migration.qbk. Use lock_t throughout work_sharing.cpp,
instead of lock_t, lock_count and explicit std::unique_lock<std::mutex>
declarations. Unify treatment of main and dispatcher fibers.

Clarify thread-safety requirements on sched_algorithm::notify() and
suspend_until().

Clarify disable_interruption when rethrowing fiber_interrupted.

Consolidate future<T>::get(): returns T whether T is R, R& or void.

Mention nesting of disable_interruption (which matters) versus nesting of
restore_interruption (which doesn't). Mention that a disable_interruption
constructed within the scope of another disable_interruption is a no-op, both
itself and when passed to restore_interruption.

When packaged_task::operator()() stores a value or an exception, state "as if"
by promise::set_value() or set_exception(): the shared state is set ready.
Similarly for ~packaged_task() and ~promise() setting broken_promise.

Sprinkle links to the Allocator concept, std::allocator and
std::allocator_arg_t where referenced. Similarly for StackAllocator.

Add more cross-reference links where Fiber classes and methods are mentioned.
Also things like std::unique_lock and std::mutex.

Clarify error condition for value_pop() when channel is close()d.

Since fiber_specific_ptr::release() does not invoke cleanup, it should not
throw an exception raised during cleanup.
2016-02-11 11:27:26 -05:00
Nat Goodspeed
3b9e9a3a56 Snapshot of documentation update for 2016 review.
Note effect of BOOST_USE_SEGMENTED_STACKS if StackAllocator is not explicitly
passed.

Introduce function_heading_for QuickBook template to allow separate
descriptions of swap(fiber), swap(packaged_task) and swap(promise).

Document async() using C++14 std::result_of_t and std::decay_t, aligning with
std::async() documentation.

Rework when_any / when_all examples to use unbounded_channel throughout, since
we always close() the channel after the first value anyway. bounded_channel
doesn't really add much value here.

Make wait_first_outcome_impl() infer its channel pointer type. That way we can
reuse that function instead of coding a separate wait_all_until_error_impl(),
which differs only in using the nchannel facade instead of directly pushing to
unbounded_channel.

Explain use of std::bind() to bind a lambda.

Use a more nuanced discussion of promise lifetime in write_ec() example
function.

Use condition_variable::wait(lock, predicate) in a couple places in
work_sharing.cpp example.
2016-02-06 23:17:04 -05:00
Oliver Kowalke
59a4317bf3 use condition_variable::wait(lk,pred) 2016-02-02 17:07:29 +01:00
Oliver Kowalke
6567fde460 add initializer brackets to yeld in example 2016-02-02 17:07:01 +01:00
Oliver Kowalke
1ace8bbb36 make async_result::get() an interruption point 2016-01-31 18:14:24 +01:00
Oliver Kowalke
3ac9dde4d0 update asio integration example 2016-01-31 16:48:04 +01:00
Oliver Kowalke
284bdf6f78 fix asio integration - skip promise_handler 2016-01-31 16:14:14 +01:00
Oliver Kowalke
62b2a52857 some fixes for asio integration - promise problematic 2016-01-31 11:00:08 +01:00
Oliver Kowalke
51f4cb1a26 update asio integration in directory examples 2016-01-29 17:04:15 +01:00
Oliver Kowalke
3cfe41c01e fix asio/round_robin.hpp
block thread only in io_service::rune_one() if no fibers ready
2016-01-26 11:54:27 +01:00
Oliver Kowalke
dd661d4e5d attempt of better integration with asio 2016-01-25 21:48:18 +01:00
Oliver Kowalke
a4c2315c54 fix examples because autoreset_event was removed 2016-01-25 21:47:58 +01:00
Oliver Kowalke
172d5569a6 fix typo in comment of example work_sharing.cpp 2016-01-20 19:44:59 +01:00
Oliver Kowalke
f01cf1daff update migration example 2016-01-20 19:42:26 +01:00
Oliver Kowalke
34be91cb3c update docu migration 2016-01-17 21:08:29 +01:00
Oliver Kowalke
d541e88a4b update documentation 2015-12-29 15:04:13 +01:00
Oliver Kowalke
ff8537d153 re-enable example wait_stuff 2015-12-17 20:05:49 +01:00
Oliver Kowalke
b196c2d872 disable example wait_stuff from build 2015-12-14 20:45:46 +01:00
Oliver Kowalke
db180f08da relax to C++11 2015-12-12 23:19:33 +01:00
Oliver Kowalke
6034c1b09b reenable Nat's promise_handler impl 2015-12-05 15:14:54 +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
ca655a84d9 execute func + set active fiber inside context::resume() 2015-11-22 14:28:09 +01:00
Oliver Kowalke
a71e19ec4b fix work-stealing example 2015-11-11 07:18:32 +01:00
Oliver Kowalke
5973f6a262 add work-stealing example 2015-10-21 15:26:55 +02:00
Oliver Kowalke
f743b63bc0 replace context::attach()/detach() by context::migrate() 2015-10-21 15:25:12 +02:00
Oliver Kowalke
edd439233a fixups for asio examples 2015-10-17 14:41:53 +02:00
Oliver Kowalke
5345d810a8 asio: executed dummy fiber after sleep-timer expires 2015-10-14 13:43:14 +02:00
Oliver Kowalke
51c1a96c4d introduce attach/detach of context 2015-10-14 13:37:44 +02:00
Oliver Kowalke
7617b74e57 remove second unlinking from worker-queue in work-sharing example 2015-10-12 22:05:15 +02:00
Oliver Kowalke
c07115115c work sharing example: some modifications 2015-10-12 18:55:54 +02:00
Oliver Kowalke
0deb75a699 modify work-sharign example 2015-10-12 18:44:21 +02:00