comp.lang.ada
 help / color / mirror / Atom feed
From: Richard Riehle <richard@adaworks.com>
Subject: Re: Multiple task bodies for one task type?
Date: Tue, 18 Sep 2001 12:01:11 -0700
Date: 2001-09-18T18:58:49+00:00	[thread overview]
Message-ID: <3BA799F7.BE0EE6FD@adaworks.com> (raw)
In-Reply-To: 3ba5c37f.6210990@news.demon.co.uk

John McCabe wrote:

> On Sat, 15 Sep 2001 00:26:01 GMT, Darren New <dnew@san.rr.com> 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





  parent reply	other threads:[~2001-09-18 19:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-15  0:26 Multiple task bodies for one task type? Darren New
2001-09-17  9:37 ` John McCabe
2001-09-17 14:01   ` Tucker Taft
2001-09-18 19:01   ` Richard Riehle [this message]
2001-09-18 21:03     ` Darren New
2001-09-18 21:26     ` tmoran
2001-09-17 14:15 ` Stephen Leake
replies disabled

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