Revert "Allow nested calls to completion handler when using yield_context."

This reverts commit 81242906a5.
This commit is contained in:
Christopher Kohlhoff 2015-02-16 08:45:54 +11:00
parent 81242906a5
commit a5712beb31
2 changed files with 9 additions and 26 deletions

View File

@ -19,7 +19,6 @@
#include "asio/associated_allocator.hpp"
#include "asio/associated_executor.hpp"
#include "asio/async_result.hpp"
#include "asio/detail/atomic_count.hpp"
#include "asio/detail/handler_alloc_helpers.hpp"
#include "asio/detail/handler_cont_helpers.hpp"
#include "asio/detail/handler_invoke_helpers.hpp"
@ -42,7 +41,6 @@ namespace detail {
: coro_(ctx.coro_.lock()),
ca_(ctx.ca_),
handler_(ctx.handler_),
ready_(0),
ec_(ctx.ec_),
value_(0)
{
@ -52,23 +50,20 @@ namespace detail {
{
*ec_ = asio::error_code();
*value_ = ASIO_MOVE_CAST(T)(value);
if (--*ready_ == 0)
(*coro_)();
(*coro_)();
}
void operator()(asio::error_code ec, T value)
{
*ec_ = ec;
*value_ = ASIO_MOVE_CAST(T)(value);
if (--*ready_ == 0)
(*coro_)();
(*coro_)();
}
//private:
shared_ptr<typename basic_yield_context<Handler>::callee_type> coro_;
typename basic_yield_context<Handler>::caller_type& ca_;
Handler handler_;
atomic_count* ready_;
asio::error_code* ec_;
T* value_;
};
@ -81,7 +76,6 @@ namespace detail {
: coro_(ctx.coro_.lock()),
ca_(ctx.ca_),
handler_(ctx.handler_),
ready_(0),
ec_(ctx.ec_)
{
}
@ -89,22 +83,19 @@ namespace detail {
void operator()()
{
*ec_ = asio::error_code();
if (--*ready_ == 0)
(*coro_)();
(*coro_)();
}
void operator()(asio::error_code ec)
{
*ec_ = ec;
if (--*ready_ == 0)
(*coro_)();
(*coro_)();
}
//private:
shared_ptr<typename basic_yield_context<Handler>::callee_type> coro_;
typename basic_yield_context<Handler>::caller_type& ca_;
Handler handler_;
atomic_count* ready_;
asio::error_code* ec_;
};
@ -184,10 +175,8 @@ public:
explicit async_result(detail::coro_handler<Handler, T>& h)
: handler_(h),
ca_(h.ca_),
ready_(2)
ca_(h.ca_)
{
h.ready_ = &ready_;
out_ec_ = h.ec_;
if (!out_ec_) h.ec_ = &ec_;
h.value_ = &value_;
@ -196,8 +185,7 @@ public:
type get()
{
handler_.coro_.reset(); // Must not hold shared_ptr to coro while suspended.
if (--ready_ != 0)
ca_();
ca_();
if (!out_ec_ && ec_) throw asio::system_error(ec_);
return ASIO_MOVE_CAST(type)(value_);
}
@ -205,7 +193,6 @@ public:
private:
detail::coro_handler<Handler, T>& handler_;
typename basic_yield_context<Handler>::caller_type& ca_;
detail::atomic_count ready_;
asio::error_code* out_ec_;
asio::error_code ec_;
type value_;
@ -219,10 +206,8 @@ public:
explicit async_result(detail::coro_handler<Handler, void>& h)
: handler_(h),
ca_(h.ca_),
ready_(2)
ca_(h.ca_)
{
h.ready_ = &ready_;
out_ec_ = h.ec_;
if (!out_ec_) h.ec_ = &ec_;
}
@ -230,15 +215,13 @@ public:
void get()
{
handler_.coro_.reset(); // Must not hold shared_ptr to coro while suspended.
if (--ready_ != 0)
ca_();
ca_();
if (!out_ec_ && ec_) throw asio::system_error(ec_);
}
private:
detail::coro_handler<Handler, void>& handler_;
typename basic_yield_context<Handler>::caller_type& ca_;
detail::atomic_count ready_;
asio::error_code* out_ec_;
asio::error_code ec_;
};

View File

@ -18,6 +18,6 @@
// ASIO_VERSION % 100 is the sub-minor version
// ASIO_VERSION / 100 % 1000 is the minor version
// ASIO_VERSION / 100000 is the major version
#define ASIO_VERSION 101100 // 1.11.0
#define ASIO_VERSION 101004 // 1.10.4
#endif // ASIO_VERSION_HPP