Boost logo

Boost Users :

Subject: [Boost-users] [statechart] fifo_scheduler<>::operator() in state constructor
From: Andrew C (achinkoff_at_[hidden])
Date: 2015-02-04 09:40:46


Hi,

is it allowed to call fifo_scheduler<>::operator() from state constructor?

If yes, then let's assume "scheduler" and "processor" are objects of
"fifo_scheduler<>" and "fifo_scheduler<>::processor_handle" types
respectively in the some state constructor code below:

State(my_context ctx): my_base(ctx)
{
    boost::intrusive_ptr<Event> pEvent(new Event());

    // If both lines [A] and [B] are uncommented
    // then "unconsumed_event" method is called twice.
    // If just line [A] is uncommented then "unconsumed_event" method is
called.
    // If just line [B] is uncommented then certain "react" method is
called.

    // scheduler.queue_event(processor, pEvent); // [A]
    // this->post_event(Event()); // [B]

    scheduler();
}

Note constructor calls "scheduler()" at the end.

Other questions:
Is this code correct and runs expectedly as described in comments?
Why "unconsumed_event" is called if use "queue_event" instead of
"post_event"?

Thanks,
Andrew.



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