From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2fa4069595cb9ef7 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!k3g2000prl.googlegroups.com!not-for-mail From: Gene Newsgroups: comp.lang.ada Subject: Re: Breaking a circularity Date: Mon, 28 Mar 2011 14:31:32 -0700 (PDT) Organization: http://groups.google.com Message-ID: <88c28312-fdb7-42ab-8ad4-292e5a2a27ad@k3g2000prl.googlegroups.com> References: NNTP-Posting-Host: 134.240.241.2 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301347893 26835 127.0.0.1 (28 Mar 2011 21:31:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 28 Mar 2011 21:31:33 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k3g2000prl.googlegroups.com; posting-host=134.240.241.2; posting-account=-BkjswoAAACC3NU8b6V8c50JQ2JBOs04 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30729; InfoPath.2; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19524 Date: 2011-03-28T14:31:32-07:00 List-Id: On Mar 28, 6:15=A0am, Simon Wright 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.