Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-users][StateChart] event creation/destruction
From: Jens Weller (JensWeller_at_[hidden])
Date: 2009-02-25 07:45:51


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 <boost.lists_at_[hidden]>
> An: boost-users_at_[hidden]
> 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

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