Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Coroutine and Object Inheritance
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2013-12-19 09:06:28

2013/12/19 Carlos Ferreira <carlosmf.pt_at_[hidden]>

> Hello to all.
> I need some help using the Boost.Coroutine lib.
> I wanted to use the coroutines as objects and for that, I tried to build a
> simple object and inherit the boost::coroutines::coroutine template.
> ex:
> class SimpleObj : public boost::coroutines::coroutine<SimpleObj>{
> private:
> std::unique_ptr<boost::asio::ip::tcp::socket> tcpSkt_uPtr;
> std::unique_ptr<boost::asio::ip::tcp::acceptor> acc_uPtr;
> public:
> SimpleObj(std::shared_ptr<boost::asio::io_service> ioService_ptr,
> boost::asio::ip::tcp::endpoint &endPoint);
> ~SimpleObj();
> void run();
> };
> Is this right? Can I actually inherit from
> the boost::coroutines::coroutine template ?
> If yes, how can I proceed from here, to use the run() object method as the
> coroutine itself, with an io_service provided through the constructor ?

1.) do you know that boost.asio integrates boost.coroutine? example can be
read at
2.) coroutine<> is a type holder, e.g. you have to derive from
coroutine<>::push_type or coroutine<>::pull_type
3.) usually you would not track SimpleObj as is-a-coroutine -> I suggest to
aggregate coroutine<> instead derive from it

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at