comp.lang.ada
 help / color / mirror / Atom feed
From: Gene <gene.ressler@gmail.com>
Subject: Re: Breaking a circularity
Date: Mon, 28 Mar 2011 14:31:32 -0700 (PDT)
Date: 2011-03-28T14:31:32-07:00	[thread overview]
Message-ID: <88c28312-fdb7-42ab-8ad4-292e5a2a27ad@k3g2000prl.googlegroups.com> (raw)
In-Reply-To: m2lizzpn4j.fsf@pushface.org

On Mar 28, 6:15 am, Simon Wright <si...@pushface.org> wrote:
> How is the Event_Queue going to know which instance of State_Type to
> pass to a call of Handle (State, Event)?

There is currently only one state per simulation. The user of an
Event_Queue
instantiation is in a tight loop removing events from its event queue
(which is embedded in its state), then calling Handle(State, Event)
using its current state.  This is dispatched to the correct handler
based on (derived) event type. Handlers often schedule new events
in the same event queue.  It's essentially a callback.  The state is
the callback's execution context.
>
> Could the same State instance be passed to more than one Event_Queue?
>

It's easy to imagine simulations needing more than one event queue.
These would all need access through the state. But the current
application has only a single queue.

> Will you really be using different State_Types? (just checking.)

Not in this version, but it's foreseeable.

>
> You could try constraining an Event_Queue by "access State_Type'Class".
>
> Should State_Type be tagged as well as Event_Type? (I realise this ends
> up double-dispatching in Handle, would need to be class-wide in -
> probably - State_Type.)
>
> I think that with this sort of problem you are going to have to bite the
> bullet and use access and controlled types (well, controlled if you are
> going to delete queues. If not, why bother?)

Thanks for the ideas.



  reply	other threads:[~2011-03-28 21:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28  4:11 Breaking a circularity Gene
2011-03-28  9:59 ` Ludovic Brenta
2011-03-28 11:37   ` Simon Wright
2011-03-28 22:38     ` Gene
2011-03-29  3:01       ` Randy Brukardt
2011-03-28 19:47   ` Gene
2011-03-28 10:15 ` Simon Wright
2011-03-28 21:31   ` Gene [this message]
2011-03-28 11:06 ` Martin
2011-03-28 22:26   ` Gene
2011-03-29 16:28     ` Martin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox