Boost logo

Boost Users :

Subject: Re: [Boost-users] [MSM] state transitions and exceptions
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2012-03-29 16:09:19


> Jurai,
>
> On Thu, Mar 29, 2012 at 7:07 PM, Juraj Ivančić <juraj.ivancic_at_[hidden]>
> wrote:
>> I know how you feel. MSM is an awesome library. Unfortunately compilers
>> tend
>> to disagree :)

I'd say compilers should be blamed for this ;-) (I'm still wondering how it
can be that compilers make such a poor use of my 6 cores with hyperthreading
when compile a single object file...)
Typically, boost forces compiler writers to improve.
But yes, that's the deal. MSM handles a lot for you at compile time to get
features, the best speed and ease of use at the cost of longer compile time.

> Indeed. I am having massive trouble boost.binding the process_event()
> function, which I call from within a threaded pool like thingy. It was
> so bad, I had to macro wrapper functions around it. Not even the usual
> static_cast trick helped. But this is something I can live with,
> considering all the benefits.

process_event is a template function, which means boost.bind requires you to
use a function pointer.
If what you mean is generating an event from an asio handler, I usually use
the following (simplified) solution (which I plan to add to a coming paper
with msm + asio) (from memory, did not try to compile):
template <class Fsm>
struct handle_write
{
   void operator()(const boost::system::error_code& error) const
  {
      if (error) fsm_->process_event(WriteError());
      else fsm_->process_event(WriteDone());
   }
   Fsm* fsm_;
};

HTH,
Christophe


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