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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,550291bc2bbf5019 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-18 12:28:49 PST Path: archiver1.google.com!news2.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!out.nntp.be!propagator-SanJose!news-in!news.mindspring.net!not-for-mail From: Richard Riehle Newsgroups: comp.lang.ada Subject: Re: Multiple task bodies for one task type? Date: Tue, 18 Sep 2001 12:01:11 -0700 Organization: AdaWorks Software Engineering Message-ID: <3BA799F7.BE0EE6FD@adaworks.com> References: <3BA2A012.1C2A2903@san.rr.com> <3ba5c37f.6210990@news.demon.co.uk> Reply-To: richard@adaworks.com NNTP-Posting-Host: 9e.fc.cc.b1 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 18 Sep 2001 18:58:49 GMT X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:13162 Date: 2001-09-18T18:58:49+00:00 List-Id: John McCabe wrote: > On Sat, 15 Sep 2001 00:26:01 GMT, Darren New wrote: > > You may be able to implement someting like this using a discriminant > on the task type. You would have to include all possible variations on > the code within a case statement in the task. There may be other ways > of course! It is not possible to have an array of tasks with discriminants unless it is an array of access values to the task type. This is much like the array of varying length strings, or array of tagged types someone called a "ragged array." Even in this case, it will be necessary for each task to include control logic to behave differently in different circumstances. This is not the same as having a different body. One possible solution to this is to use the discriminant to trigger a delegation effect. Ada is unique in its direct support for true delegation through the requeue mechanism. In this case, an entry can be requeued to a different task. Although you cannot pass new parameters in the requeue, each task (delegatee) can have a different body. The model can be as simple as a router that has no other role than to delegate work based on some set of characteristics of the entry at the beginning of rendezvous. To further empower this design, one could requeue (delegate) to/through a protected object for improved security of the entire design. Delegation is a powerful capability in Ada and few languages support it as directly, or in as pure a form, as Ada through its requeue feature. Richard Riehle richard@adaworks.com