Boost logo

Boost Users :

Subject: [Boost-users] boost::statechart - two async machines in one process?
From: Dick Bridges (Dick.Bridges_at_[hidden])
Date: 2013-02-25 13:15:48


I've been using asynchronous boost::statechart for 5+ years but that doesn't
seem to count for much in this instance. I've wrapped myself around the axel
and have no idea how to proceed. Any help would be greatly appreciated.

I am attempting to create a program that contains two separate classes, each
built on a boost::statechart state machine. The classes are similar but there
is one-and-only-one class a and it creates instances of class b. At least, that
was the plan.

(Apologies if this diagram doesn't format correctly. Outlook is NOT being cooperative.)
  _______________________ ________________________
| boost::statechart | | boost::statechart |
|______________________| |________________________|
                         ^ ^
 _________|______________ _________|______________
| struct a_statechart | | struct b_statechart |
|_______________________| |_______________________|
                         | |
 _________O____________ __________O___________
| struct a_impl | | struct b_impl |
|----------------------------------| |-----------------------------------|
| fifo_scheduler sched_ | | fifo_scheduler sched_ |
| processor_handle asm_ | | processor_handle bsm_ |
| boost::thread thread_ | | boost::thread thread_ |
|_____________________| |______________________|
                         | |
 _________o____________ _________o____________
| struct a | | struct b |
|_____________________| |______________________|

However, if the class b processor_handle (bsm_) is initialized, the class a
state machine doesn't react to *any* events. If I comment out the bsm_
initialization, the class a state machine handles events as expected. If bsm_
is initialized (with our without creating the thread), the class a state
machine doesn't respond to any event. The results are exactly the same if bsm_
is assigned in the ctor.

Both asm_ and bsm_ are initialized in the ?_impl ctor:
  [usual stuff]:
  sched_(true), ?sm_( sched_.create_processor< ?_statechart >() ), thread_() {

FWIW, The state machines in both classes are assigned a thread in the ?_impl ctor:
  boost::thread tmp( bind( &fifo_scheduler<>::operator(), &sched_, 0 ) );
  thread_.swap( tmp );

Any assistance will be greatly appreciated.

Regards,
Dick Bridges         
The opinions and data in this missive are my own and do not necessarily represent the positions, strategies, or opinions of Western Digital Corporation.

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

Glenda: http://glenda.cat-v.org/gallery/


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