Boost logo

Boost Users :

From: Jarl Friis (jarl_at_[hidden])
Date: 2008-03-10 09:14:04


"Andreas Huber" <ahd6974-spamboostorgtrap_at_[hidden]> writes:

> Hi Jarl

That's what I thought... However the context I am requesting this
feature is VERY controlled.
It's in a unit test. Everything is in one thread, I wait for the
scheduler to process all events, and then I want probe the state and
verify correct state. It may sound like test of the statechartlibrary
itself. It's not; I am testing that I have correctly defined my
statemachine.

>> So is there a way to come from sc::fifo_scheduler<>::processor_handle
>> to AsyncMachine (which inherits sc:asynchronous_state_machine)?
>
> No, for the same reasons. A sc:asynchronous_state_machine<> subtype is
> serviced by the fifo_scheduler thread. Directly accessing it from a
> different thread would again open the door to race-conditions or dead-locks.

Yes, under normal conditions (hostile production environment). But not
in test envs.

> The proper way to query an asynchronous state machine is by sending it a
> special event carrying a boost::function object.

Interesting, that sounds like a feasible solution for the test. The
function could probably be the assertion itself.

Thanks for the answer, I might have a look at it.

Jarl


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