2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-10 23:32:28 +00:00
Commit Graph

161 Commits

Author SHA1 Message Date
Nat Goodspeed
d653cbdcc6 Finish proofreading pass.
Add a note to the condition_variable::wait_for(..., pred) overload.

fiber_specific_ptr::reset() has no default argument.

Remove mention of launch policy deferred, since no API accepts a launch
policy argument.

Copy construction or copy assignment of a shared_future leaves other.valid()
unchanged. It won't be 'true' unless it was 'true' before.

Mention that [shared_]future::get_exception_ptr() does not invalidate.

Note that 'blocks' and 'suspends' are used interchangeably.

Add some cross-references; add link to std::allocator_arg_t. Clarify the
cross-reference to the paragraph describing BOOST_FIBERS_NO_ATOMICS.

Reformat some overly-long source lines.
2015-09-03 09:16:09 -04:00
Nat Goodspeed
bcdb555821 Use std::shared_ptr and std::make_shared for promise_handler.
Publish promise_handler::promise_ptr and use it in asio_handler_invoke() for
consistency.
2015-09-03 08:47:25 -04:00
Oliver Kowalke
be3d67a109 add end marker to example priority 2015-09-02 20:29:09 +02:00
Oliver Kowalke
52c03cb5fd fix merge error 2015-09-02 19:56:26 +02:00
Oliver Kowalke
ba35ac6de2 update documentation 2015-09-02 19:43:33 +02:00
Oliver Kowalke
a173c047a6 update documentation 2015-09-02 19:41:08 +02:00
Nat Goodspeed
37a0490bbd Fix bug in this_fiber::properties<>().
When the running thread's main fiber calls this_fiber::properties<>() without
yet having passed through sched_algorithm_with_properties::awakened(), which
is what actually instantiates the fiber_properties subclass, you could end up
without a properties instance. Fortunately there's an easy workaround: call
yield().

Remove that workaround from examples/priority.cpp.
2015-09-01 20:21:13 -04:00
Nat Goodspeed
aeaef6510f Reverse advice about when to set the properties for a new fiber.
Change which example code we show for this_fiber::properties<>() and
fiber::properties<>().
2015-09-01 19:55:33 -04:00
Nat Goodspeed
11b06c25dd Fix bug in priority_scheduler::property_change().
The complex logic to make a single pass through the ready queue to find the
old location and also the new insertion point was unfortunately error-prone.
Recast it as two separate passes: a simple search loop to find and unlink the
fiber_context*, then a call to awakened() to reinsert it in the correct place.
2015-09-01 19:16:47 -04:00
Oliver Kowalke
82143be5aa update documentation + formating 2015-09-01 17:32:07 +02:00
Oliver Kowalke
fefffd37eb update documentation 2015-09-01 17:17:38 +02:00
Oliver Kowalke
5f6df41bc7 first part of formating example wait_stuff 2015-08-31 21:53:47 +02:00
Nat Goodspeed
e3bb470376 Fill in section on adapting to nonblocking I/O. 2015-08-31 11:29:26 -04:00
Nat Goodspeed
2ed2bb4827 Add when_all_members() description. 2015-08-31 10:38:40 -04:00
Nat Goodspeed
f15fccb4b9 Add wait_all_collect_errors() description. 2015-08-31 10:08:31 -04:00
Nat Goodspeed
cc8acb1fee Add wait_all_until_error(), wait_all_until_error_source() description. 2015-08-31 10:00:38 -04:00
Nat Goodspeed
56191d5190 Add wait_all_values(), wait_all_values_source() description. 2015-08-31 08:15:06 -04:00
Nat Goodspeed
5cb215f741 Add wait_all_simple() description. 2015-08-30 20:49:45 -04:00
Nat Goodspeed
53127efe42 Add wait_first_value_het() description. 2015-08-30 19:56:40 -04:00
Nat Goodspeed
ec251c3c02 Add wait_first_success() description. 2015-08-30 19:28:44 -04:00
Nat Goodspeed
bed11fe0a1 Add wait_first_outcome() description. 2015-08-30 18:42:50 -04:00
Nat Goodspeed
2c36b37122 Answered my own question about exception in detached fiber. 2015-08-30 17:41:20 -04:00
Nat Goodspeed
34ec067a1f Add QuickBook markup for wait_first_value() section. 2015-08-29 21:34:55 -04:00
Nat Goodspeed
a8debb9201 Add first when_any passage (wait_first_simple())... work in progress. 2015-08-29 19:42:53 -04:00
Nat Goodspeed
ad1d3d118a Introduce wait_all_members_get() to restore asynchrony.
Passing the futures from the argument-pack functions through a function-call
boundary forces the runtime to perform all the async() calls _first,_ then
make a separate pass through the futures to obtain results.
2015-08-29 14:17:45 -04:00
Nat Goodspeed
9c1b412f7e Naive implementation of wait_all_members() is in fact synchronous. 2015-08-29 14:05:23 -04:00
Nat Goodspeed
f384143d04 Add wait_all_collect_errors() plus example usage. 2015-08-29 13:26:52 -04:00
Nat Goodspeed
5e30a4647b Add wait_all_until_error(), wait_all_until_error_source(), plus examples. 2015-08-29 13:10:01 -04:00
Nat Goodspeed
9c7a0b7bc5 Add wait_all_values(), wait_all_values_source(), plus example usage. 2015-08-29 12:35:25 -04:00
Nat Goodspeed
e9a234d06b Intersperse example calling code with implementations.
Introduce Runner and Example classes to collect and ultimately run lambdas
illustrating use of each different wait_something() variant.

Move Verbose up to the top for use by Runner. Similarly, move sleeper() for
use by those lambdas.

The body of main() then reduces to a Runner::run() call.
2015-08-29 09:08:20 -04:00
Nat Goodspeed
02eb362de5 wait_all_simple() can no longer share wait_first_simple_impl().
Now that wait_first_simple() is again based on Done (a bool protected by a
condition variable) rather than a barrier(2), have to introduce
wait_all_simple_impl() to manage the barrier.
2015-08-29 08:35:46 -04:00
Nat Goodspeed
ab32dbe34a Revert "Remove Done wrapper: fibers::barrier encapsulates that for us."
This reverts commit 59a3afd209, reinstating the
Done wrapper.

While it is true that a barrier(2) will wake up when the second fiber calls
wait(), it then _resets._ This means that the _third_ fiber will wait() for
the fourth, and so on. If an odd number of fibers binds that barrier, the last
of them will hang until shutdown.

We want Done.wait() to wake up on the first notify() call, and for every
subsequent notify() call to be a no-op. Apparently Done is the correct
mechanism after all.
2015-08-29 08:25:40 -04:00
Nat Goodspeed
0c25c3a179 Add wait_all_simple(). Surprisingly like wait_first_simple()! 2015-08-29 02:49:48 +00:00
Nat Goodspeed
59a3afd209 Remove Done wrapper: fibers::barrier encapsulates that for us.
You can wait on a barrier(2) to wait for exactly one more fiber to reach it --
exactly what we need for wait_first_simple().
2015-08-29 02:34:33 +00:00
Nat Goodspeed
fc8a7c612b Add wait_first_value_het() and example usage. 2015-08-29 02:27:16 +00:00
Nat Goodspeed
18ff2286ef Rename wait_any_blah() to wait_first_blah().
Generalize sleeper() task function to be able to return different types.
2015-08-29 02:07:39 +00:00
Nat Goodspeed
37f413c357 Snapshot of wait_stuff.cpp: several wait_any() variants working.
We now have:

wait_any_value(): for when passed functions cannot throw exceptions;

wait_first_outcome(): get earliest result/exception;

wait_first_success(): get first non-exception result.
2015-08-28 15:16:48 -04:00
Nat Goodspeed
76ae45d6c2 Merge branch 'develop' of github.com:nat-goodspeed/boost-fiber into develop 2015-08-26 13:18:25 -04:00
Nat Goodspeed
7af7bd2520 Merge branch 'develop' of http://github.com/olk/boost-fiber into develop 2015-08-26 13:10:31 -04:00
Oliver Kowalke
2601e72673 let sched_algo_ be managed by unique_ptr 2015-08-26 18:59:18 +02:00
Nat Goodspeed
8cce2bb668 Merge branch 'develop' of http://github.com/olk/boost-fiber into develop 2015-08-26 11:56:11 -04:00
Oliver Kowalke
1546533700 examples: priority_scheduler must live long enought
- ~fiber_manager() calls sched_algorithm::pick_next()
- therefore priority_scheudler must live long enough in order to
  be called by ~fiber_manager()
2015-08-26 17:50:12 +02:00
Nat Goodspeed
0f7b6ae71c Add notes that echo_client.cpp and echo_client2.cpp are borrowed from asio.
The casual reader, on encountering these in the Fiber examples directory,
might otherwise assume they're intended to illustrate something about the
Fiber library.
2015-08-25 13:07:35 -04:00
Nat Goodspeed
c52a914906 Add examples/when_stuff.cpp illustrating when_any_simple().
when_any_simple() is "simple" in the sense that we don't care about return
values or possible exceptions -- we only want to know when the shortest
subtask completes.

This source is a work in progress. We intend to add more cases.
2015-08-25 10:13:25 -04:00
Oliver Kowalke
73d38028c4 code re-formating of asio examples 2015-08-24 20:08:56 +02:00
Oliver Kowalke
aa79e05d25 fix code format in examples 2015-08-24 19:52:00 +02:00
Nat Goodspeed
1e3e2b8887 Add callbacks.qbk about interfacing Fiber with async callbacks.
This covers both generic callbacks (adapt_callbacks.cpp,
adapt_method_calls.cpp) and custom Asio completion tokens (yield.hpp,
promise_completion_token.hpp, detail/yield.hpp, detail/promise_handler.hpp).
Mark up the relevant source files to provide code snippets for callbacks.qbk.
2015-08-24 09:28:16 -04:00
Nat Goodspeed
685ba8f16f Add examples/adapt_nonblocking.cpp.
This illustrates how Fiber can ease the problem of wrapping retries for
nonblocking I/O in an event-driven program.
2015-08-23 17:20:49 -04:00
Nat Goodspeed
68044bb349 Don't embed semantically meaningful function calls in assert(). 2015-08-23 17:15:30 -04:00
Nat Goodspeed
550aae5029 Add examples/adapt_method_calls.cpp.
This illustrates how to interface a synchronous Fiber function with an async
API whose notification consists of an abstract base class with virtual
success/error methods.
2015-08-23 11:53:33 -04:00