Commit Graph

36 Commits

Author SHA1 Message Date
oliver Kowalke
bf2b5978d2 fix examples 2017-11-08 13:35:18 +01:00
Oliver Kowalke
b53e167a68 support for channels refactored
- buffered_channel: MPMC with lock-free guarantees
- unbuffered_channel: rendezvous point
2016-10-30 19:33:49 +01:00
Oliver Kowalke
ce962f9688 (un)bounded_channel renamed to (un)bounded_queue 2016-10-13 20:17:01 +02:00
Nat Goodspeed
ea0c16080b A few more documentation-related edits 2016-02-15 17:12:56 -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
ff8537d153 re-enable example wait_stuff 2015-12-17 20:05:49 +01:00
Oliver Kowalke
48d652adab add example wait_stuff 2015-09-29 20:27:33 +02:00
Oliver Kowalke
253d981f52 examples added 2015-09-29 17:55:46 +02:00
Oliver Kowalke
eafeaaae01 remove examples and tests 2015-09-16 19:12:57 +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
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