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

74 Commits

Author SHA1 Message Date
Oliver Kowalke
57267ec957 remove support for fiber interruption 2016-04-19 18:16:31 +02:00
oliver Kowalke
0a911f4ab5 some modifications for autoecho example 2016-04-14 09:14:20 +02:00
oliver Kowalke
cd24224008 change asio examples regarding to run_svc() 2016-04-12 08:39:25 +02:00
oliver Kowalke
76127cc268 asio example: scheduler must not move lambda
- the lambda posted inside iasio::rond_robin will be shared by different
  threads running io_service::run()
- the lambda must remain/executed by the thread
- re-introduction of run_svc() method
2016-04-12 08:31:49 +02:00
oliver Kowalke
171b2be879 assert in autoecho aexample
- assert if context, that has to be migrated, is equal to active context
  because that should never be possible
2016-04-11 08:21:34 +02:00
Nat Goodspeed
9b3559dd49 Remove 'yield_hop' and the whole allow_hop_ mechanism.
Given the necessity for fibers::asio::round_robin to share its ready queue
among all threads calling io_service::run() on the same io_service instance,
the capability to allow hop (or not) in the fibers::asio::yield mechanism is
redundant.
2016-04-06 12:17:35 -04:00
Nat Goodspeed
f13c24bd66 Launch client fibers on alternate thread. 2016-04-06 12:17:34 -04:00
Nat Goodspeed
e2d4738c2a Merge branch 'develop' of github.com:nat-goodspeed/boost-fiber into develop 2016-04-05 21:18:33 -04:00
Nat Goodspeed
3b9c8f0b46 Add autoecho.cpp to drive echo client/server automatically. 2016-04-05 21:17:35 -04:00
Nat Goodspeed
abfc4cab2a Defend yield_handler_base::operator() against immediate callback.
If the async operation invoked by the asio async function immediately calls
yield_handler_base::operator() even before control reaches
async_result_base::get(), which would suspend the calling fiber, the context*
bound by yield_handler_base's constructor is still the active() context. This
may not be passed to context::migrate(). It probably shouldn't be passed to
context::set_ready(), either.
2016-04-02 12:16:17 -04:00
Nat Goodspeed
d3b959f05a Merge branch 'develop' of github.com:olk/boost-fiber into develop 2016-03-27 22:49:46 -04:00
Nat Goodspeed
4ebc1ed2f4 Update fibers::asio::yield doc for current implementation. 2016-03-27 22:46:38 -04:00
oliver Kowalke
e8f922a8f1 some code formating 2016-03-24 08:07:34 +01:00
oliver Kowalke
fb21bee1cb fixes form asio integration 2016-03-24 07:53:38 +01:00
Nat Goodspeed
46c696f5f6 Eliminate obsolete promise_completion_token.hpp header.
This was used in an earlier implementation of use_future (no longer present)
and fibers::asio::yield (completely reimplemented).
2016-03-23 21:51:34 -04:00
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
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
e43cf5b1ac enum for context types 2016-02-15 19:49:22 +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
6034c1b09b reenable Nat's promise_handler impl 2015-12-05 15:14:54 +01:00
Oliver Kowalke
726d4d51b9 ++14 polishing 2015-12-01 21:07:11 +01: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
b032457397 asio examples added 2015-10-10 21:50:22 +02:00
Oliver Kowalke
ae67ee1694 asio's spawn() 2015-10-05 19:23:16 +02:00
Oliver Kowalke
5d71a4f8cd asio examples 2015-10-04 20:08:21 +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
2cd1d39f12 fix clang compiler error regarding missing typename 2015-09-08 18:58:36 +02: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
fefffd37eb update documentation 2015-09-01 17:17:38 +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
Oliver Kowalke
73d38028c4 code re-formating of asio examples 2015-08-24 20:08:56 +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
f3213aae54 use_future.hpp and yield.hpp no longer need handler_invoke_hook.hpp. 2015-08-22 14:43:16 -04:00
Nat Goodspeed
53d4f4b166 Reimplement boost::fibers::asio::yield with promise/future.
In essence, yield_t et al. become very like use_future_t et al. The only real
difference is the async_result return type and get() method. Factor out common
functionality into promise_completion_token and promise_handler.

Remove the boost::fibers::asio::spawn() function and its basic_yield_context
infrastructure. Fix up all existing references in example source code.
2015-08-22 14:22:20 -04:00