Boost Users :
Subject: Re: [Boost-users] Using Coroutines in the Visitor Pattern (use-case: BGL event visitor)
From: Nat Goodspeed (nat_at_[hidden])
Date: 2016-01-14 13:39:37
On Thu, Jan 14, 2016 at 4:31 AM, alex <alexhighviz_at_[hidden]> wrote:
> Boost Coroutine has changed (and surely improved) a lot since then. I would
> be curious to know the computational cost of the inversion of control using
> your method. Have you tried to quantify it?
That's an interesting question. Partly, of course, it depends on what
you're comparing it to. Throwing exceptions from within a visitor, and
then reconstructing state back down to the point at which the
algorithm was last interrupted? Intuition suggests that the coroutine
approach beats that handily.
Likewise, I'm intuitively certain that using stackful coroutines is
significantly cheaper than using threads with locks. The OS doesn't
participate in coroutine context switching at all, and since the
coroutines are simply passing control back and forth within the same
thread, no lock objects are needed.
I think you mean: what's the cost of the context switching? Oliver
Kowalke (author of the Coroutine library) made this remark in private
> I would suggest that you use boost.coroutine2 (from branch develop
> + context from branch develop) - it is a little bit faster (38ns vs. 46ns)
> than boost.coroutine.
But of course that's on particular hardware. I don't know whether you
find that answer satisfactory. If not, please clarify the question?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net