Copyconstruction? Cloning? That are were my first thoughts on the problem. regards Jens Weller -------- Original-Nachricht --------
Datum: Wed, 25 Feb 2009 14:25:21 +0200 Von: Igor R
An: boost-users@lists.boost.org Betreff: [Boost-users] [boost-users][StateChart] event creation/destruction
Hello,
In my application I use a few async state-machines with lots of events. I'd like to trace some events construction/destruction balance, so I define them as follows:
volatile long eventCount; template<class MostDerived> struct EvBase : sc::event<MostDerived> { EvBase() { long c = InterlockedIncrement(&eventCount); somelog << c << std::endl; } ~EvBase() { long c = InterlockedDecrement(&eventCount); somelog << c << std::endl; } }; // inherit EvBase directly struct Ev1 : EvBase<Ev1> {}; struct Ev2 : EvBase<Ev2> {}; struct Ev3 : EvBase<Ev3> {}; // inherit EvBase indirectly template<class MostDerived> struct EvIntermediate : EvBase<MostDerived> {}; struct Ev4 : EvIntermediate<Ev4> {}; When I run the application, I see that at some stage the counter goes negative, and its tendency is to get more and more negative. I guess I don't realize something important about the sc::event, so I'd appreciate enlightment on this.
Thanks,
Igor'.
-- Computer Bild Tarifsieger! GMX FreeDSL - Telefonanschluss + DSL für nur 17,95 ¿/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a