← Back to team overview

kicad-developers team mailing list archive

Re: Coroutines, in general

 

Hi,

For what it's worth, I've been bitten by some changes in boost
coroutine(s?)(2) and there are actually two different interfaces
(coroutines and coroutines2) and the previous is deprecated.

My workaround is to do the following in our project to get something that
works both before boost 1.55 and after. One of the more non-obvious
behavioral changes were whether the coroutine is automatically invoked or
not by mere construction of my CoroPull type (see below).

#include <boost/version.hpp>

#define USE_OLD_COROUTINES  (BOOST_VERSION / 100 % 1000 <= 55)

#if USE_OLD_COROUTINES
#include <boost/coroutine/coroutine.hpp>
#else
#include <boost/coroutine2/coroutine.hpp>
#endif

#if USE_OLD_COROUTINES
  typedef boost::coroutines::coroutine<void()> Coro;
  typedef Coro              CoroPull;
  typedef Coro::caller_type CoroPush;
#else
  typedef boost::coroutines2::coroutine<void> Coro;
  typedef Coro::pull_type   CoroPull;
  typedef Coro::push_type   CoroPush;
#endif

And first thing in the coroutine function to work around the automatic
invocation in the deprecated version:
  if (USE_OLD_COROUTINES) myYield();

Regards,
Joakim

On Thu, Feb 23, 2017 at 2:29 PM, Chris Pavlina <pavlina.chris@xxxxxxxxx>
wrote:

> Fair enough. Has coroutine really been as bad as context though? Seems
> we've had to resort to using some internal API functions in context,
> which really seems to be screwing us over.. :P
>
> On Thu, Feb 23, 2017 at 02:27:59PM +0100, Tomasz Wlostowski wrote:
> > On 23.02.2017 14:17, Chris Pavlina wrote:
> > > boost::coroutine? Seems the latter has a much more stable API, is
> > > it missing something we require?
> >
> > Hi Chris,
> >
> > I can't agree that either boost::context or boost::coroutine have stable
> > APIs, that's why have our own wrapper on top...
> >
> > Cheers,
> > Tom
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
>