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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5ee499d03212eed3,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-05 18:08:36 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cyclone2.usenetserver.com!usenetserver.com!news-east.rr.com!cyclone.kc.rr.com!news.kc.rr.com!news-west.rr.com!lsnws01.we.mediaone.net!typhoon.san.rr.com!not-for-mail Message-ID: <3BBE5993.1CF0069D@san.rr.com> From: Darren New Organization: Boxes! X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Dynamic dispatch again Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 06 Oct 2001 01:08:49 GMT NNTP-Posting-Host: 66.75.151.160 X-Complaints-To: abuse@rr.com X-Trace: typhoon.san.rr.com 1002330529 66.75.151.160 (Fri, 05 Oct 2001 18:08:49 PDT) NNTP-Posting-Date: Fri, 05 Oct 2001 18:08:49 PDT Xref: archiver1.google.com comp.lang.ada:13821 Date: 2001-10-06T01:08:49+00:00 List-Id: OK, I'm still trying to figure out how to make one entry call wind up calling code in different units. It seems to me that if I have a line that says requeue thing.do_it then there's only one unit in which this can be requeued. That is, there's no way to declare "thing" such that it might point to different implementations of something, as it could if it was a tagged type. Basically, what I'm looking for is a method whereby a task can wait for one of N entries to be called, take action as appropriate, and have a driver program have M of these tasks but all running different code. Essentially, I have a basic manager task doing I/O, distributing messages to "profiles". Each "profile" can get the same set of messages (start, stop, are you ready, here's a message), but each responds to the messages in different ways. Some of the calls need to be blocking as well (like "are you ready") or the programming's gonna be a bear. There's also a *different* task managing requests from the local side of the connection. What I have so far is here, but I can't figure out how to properly define "profile" such that "dispatch task" or "driver" can call either "profile_double" or "profile_negative" and get the right answer. Is there any possibility I'm missing something? I'd hate to have to package up the entire interface as message-passing when there's routines like "ask everyone if they're ready", and have to pick up the answers coming back asynchronously. Thanks in advance! +=+=+=+ profile.ads package profile is type profile is tagged limited null record; type profile_pointer is access all profile'class; end profile; +=+=+=+ profile_double.ads with profile; package profile_double is task type profile_double_task is entry xlate(in_in : in integer; out_out : out integer); end profile_double_task; type profile_double is new profile.profile with record tsk : profile_double_task; end record; end profile_double; +=+=+=+ profile_double.adb with profile; package body profile_double is task body profile_double_task is begin loop select accept xlate(in_in : in integer; out_out : out integer) do out_out := in_in + in_in; end xlate; or terminate; end select; end loop; end profile_double_task; end profile_double; +=+=+=+ profile_negate.ads with profile; package profile_negate is task type profile_negate_task is entry xlate(in_in : in integer; out_out : out integer); end profile_negate_task; type profile_negate is new profile.profile with record tsk : profile_negate_task; end record; end profile_negate; +=+=+=+ profile_negate.adb with profile; package body profile_negate is task body profile_negate_task is begin loop select accept xlate(in_in : in integer; out_out : out integer) do out_out := - in_in; end xlate; or terminate; end select; end loop; end profile_negate_task; end profile_negate; +=+=+=+ dispatch_task.ads with Profile; package Dispatch_Task is task type Dispatch_Task is entry set_task(p : in profile.profile_pointer); entry xlate(in_in : in Integer; out_out : out integer); end Dispatch_Task; type Dispatch_task_pointer is access all dispatch_task; end Dispatch_Task; +=+=+=+ dispatch_task.adb with profile; package body dispatch_task is task body dispatch_task is held_p : profile.Profile_Pointer; begin accept set_task(p : in profile.Profile_Pointer) do held_p := p; end set_task; loop select accept xlate(in_in : in integer; out_out : out integer) do requeue held_p.tsk; end xlate; or terminate; end select; end loop; end dispatch_task; end dispatch_task; +=+=+=+ driver.adb with dispatch_task; with profile; with profile_double; with profile_negate; with Ada.Text_IO; procedure driver is type pat is array(1..2) of dispatch_task.dispatch_task_pointer; pa : pat; i : integer; begin pa(1) := new dispatch_task.dispatch_task; pa(2) := new dispatch_task.dispatch_task; pa(1).set_task(new profile_double.profile_double); pa(2).set_task(new profile_negate.profile_negate); pa(1).xlate(100, i); Ada.Text_IO.Put_Line("First, " & Integer'Image(I)); pa(2).xlate(100, i); Ada.Text_IO.Put_Line("Second, " & Integer'Image(I)); end driver; +=+=+=+ -- Darren New San Diego, CA, USA (PST). Cryptokeys on demand. Who is this Dr. Ibid anyway, and how does he know so much?