boost-coroutine

What causes a random crash in boost::coroutine?

烂漫一生 提交于 2019-12-20 05:44:27
问题 I have a multithread application which uses boost::asio and boost::coroutine via its integration in boost::asio . Every thread has its own io_service object. The only shared state between threads are connection pools which are locked with mutex when connection is get or returned from/to the connection pool. When there is not enough connections in the pool I push infinite asio::steady_tiemer in internal structure of the pool and asynchronously waiting on it and I yielding from the couroutine

ASIO - How to stop simple coroutine based server?

别等时光非礼了梦想. 提交于 2019-12-11 08:07:57
问题 I have the following simple coroutine-based server: class Server { private: boost::asio::io_service Service; boost::asio::ip::tcp::acceptor Acceptor; boost::asio::ip::tcp::socket Socket; private: void Accept(boost::asio::yield_context Yield); void Write(boost::asio::yield_context Yield); public: Server(): Acceptor(Service), Socket(Service) {} void Open(unsigned short PortNum); void Run(); void Stop(); }; void Server::Accept(boost::asio::yield_context Yield) { boost::system::error_code ec; for

boost coroutine server crashes when writting data to client

旧城冷巷雨未停 提交于 2019-12-08 03:33:06
问题 I made my server based on boost coroutine echo server example, simply receives and writes back some data. It crashes when writing data to client, and more strangely, it only crashes when using mutiple cores. Here's the server, it reads 4 bytes and write back "OK", within 1 second as timeout: #include <winsock2.h> #include <windows.h> #include <iostream> using namespace std; #include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/asio/spawn.hpp> using namespace boost;

What's wrong with this boost::asio and boost::coroutine usage pattern?

倖福魔咒の 提交于 2019-12-07 02:42:30
问题 In this question I described boost::asio and boost::coroutine usage pattern which causes random crashes of my application and I published extract from my code and valgrind and GDB output. In order to investigate the problem further I created smaller proof of concept application which applies the same pattern. I saw that the same problem arises in the smaller program which source I publish here. The code starts a few threads and creates a connection pool with a few dummy connections (user

Boost.Coroutine not using segmented stacks

懵懂的女人 提交于 2019-12-06 08:13:00
问题 Can anyone give me an example of how I can use segmented stacks with boost coroutines? Do I have to annotate every function that is called from the coroutine with a special split-stack attribute? When I try and write a program that should use segmented stacks, it just segfaults. Here is what I have done so far https://wandbox.org/permlink/TltQwGpy4hRoHgDY The code seems to segfault very quickly, if segmented stacks were used I would expect it to be able to handle more iterations. The program

Boost.Coroutine not using segmented stacks

微笑、不失礼 提交于 2019-12-04 14:09:56
Can anyone give me an example of how I can use segmented stacks with boost coroutines? Do I have to annotate every function that is called from the coroutine with a special split-stack attribute? When I try and write a program that should use segmented stacks, it just segfaults. Here is what I have done so far https://wandbox.org/permlink/TltQwGpy4hRoHgDY The code seems to segfault very quickly, if segmented stacks were used I would expect it to be able to handle more iterations. The program errors out after 35 iterations. #include <boost/coroutine2/all.hpp> #include <iostream> #include <array

What does boost::asio::spawn do?

删除回忆录丶 提交于 2019-12-03 04:38:45
问题 I am unable to form a mental picture of how the control flow happens with spawn. When I call spawn(io_service, my_coroutine) , does it add a new handler to the io_service queue that wraps a call to the my_coroutine ? When inside the coroutine I call an async function passing it my yield_context , does it suspend the coroutine until the async operation completes? void my_coroutine(yield_context yield) { ... async_foo(params ..., yield); ... // control comes here only once the async_foo

What causes a random crash in boost::coroutine?

浪子不回头ぞ 提交于 2019-12-02 03:00:21
I have a multithread application which uses boost::asio and boost::coroutine via its integration in boost::asio . Every thread has its own io_service object. The only shared state between threads are connection pools which are locked with mutex when connection is get or returned from/to the connection pool. When there is not enough connections in the pool I push infinite asio::steady_tiemer in internal structure of the pool and asynchronously waiting on it and I yielding from the couroutine function. When other thread returns connection to the pool it checks whether there is waiting timers, it

Differences between Boost.Coroutine and Boost.Coroutine2

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 16:52:18
What are the main differences between Boost.Coroutine and Boost.Coroutine2 ? Some differences: Boost.Coroutine2 requires C++11 Boost.Coroutine provides symmetric and asymmetric coroutines, Boost.Coroutine2 only provides asymmetric coroutines. boost.coroutine2 is the follow-up project of boost.coroutine (boost.coroutine will be marked as deprecated soon) boost.coroutine2 uses class execution_context from boost.context boost.coroutine is implemented with the deprecated C-like fcontext-API from boost.context 来源: https://stackoverflow.com/questions/37343873/differences-between-boost-coroutine-and