forked from boostorg/beast
examples & tests use context instead of coroutine.
This commit is contained in:
1 parent
1841a592d6
commit
99bceb5bff
24 files changed
+156
-37
No files matched your search
+1
-1
@@ -36,7 +36,7 @@ project /boost/beast/test
|
||||
<library>/boost/beast//lib-asio/<link>static
|
||||
<boost.beast.separate-compilation>on:<library>/boost/beast//lib-beast/<link>static
|
||||
<library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/coroutine//boost_coroutine
|
||||
<library>/boost/context//boost_context
|
||||
;
|
||||
|
||||
path-constant ZLIB_SOURCES :
|
||||
|
||||
@@ -74,12 +74,14 @@ snippets()
|
||||
{
|
||||
//[code_core_1_refresher_5s
|
||||
asio::spawn(
|
||||
sock.get_executor(),
|
||||
[&sock](net::yield_context yield)
|
||||
{
|
||||
std::size_t bytes_transferred = net::async_write(sock,
|
||||
net::const_buffer("Hello, world!", 13), yield);
|
||||
(void)bytes_transferred;
|
||||
});
|
||||
},
|
||||
asio::detached);
|
||||
//]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +397,10 @@ https_get (std::string const& host, std::string const& target, error_code& ec)
|
||||
|
||||
// Set the string to return to the caller
|
||||
result = std::move(res.body());
|
||||
});
|
||||
},
|
||||
// this will capture exceptions thrown by the coroutine,
|
||||
// which we're ignoring, since we're using error_codes to capture them.
|
||||
asio::detached);
|
||||
|
||||
// `run` will dispatch completion handlers, and block until there is
|
||||
// no more "work" remaining. When this call returns, the operations
|
||||
|
||||
@@ -128,14 +128,20 @@ spawn(F0&& f, FN&&... fn)
|
||||
[&]
|
||||
{
|
||||
asio::spawn(ioc_,
|
||||
std::allocator_arg,
|
||||
boost::context::fixedsize_stack(2 * 1024 * 1024),
|
||||
[&](yield_context yield)
|
||||
{
|
||||
f(yield);
|
||||
std::lock_guard<std::mutex> lock{m_};
|
||||
if(--running_ == 0)
|
||||
cv_.notify_all();
|
||||
}
|
||||
, boost::coroutines::attributes(2 * 1024 * 1024));
|
||||
},
|
||||
[](std::exception_ptr e)
|
||||
{
|
||||
if (e)
|
||||
std::rethrow_exception(e);
|
||||
});
|
||||
});
|
||||
spawn(fn...);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user