comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: Initializing an array of tasks with discrimants
Date: Sat, 23 Nov 2019 08:28:22 -0800 (PST)
Date: 2019-11-23T08:28:22-08:00	[thread overview]
Message-ID: <91db9356-1b6a-4426-a9c7-c19613c654e8@googlegroups.com> (raw)
In-Reply-To: <qraqlj$41u$1@gioia.aioe.org>

On Saturday, November 23, 2019 at 3:29:45 AM UTC-5, Dmitry A. Kazakov wrote:
> On 2019-11-22 23:07, Jere wrote:
> > I recently ran into a situation where I had an array
> > of tasks that had discriminants (with a default), but
> > I couldn't find a simple way to initialize them.  I
> > did come up with a workaround, but wanted to see if
> > the language defined a way to do this:
> > 
> >      task type T(D: Integer := 3);
> 
> The cleanest way would be a protected generator of unique task IDs:
> 
>     protected ID is
>        procedure Get (ID : out Integer);
>     private
>        Free : Integer := 0;
>     end ID;
> 
>        procedure Get (ID : out Integer) is
>        begin
>            ID := Free;
>            Free := Free + 1;
>        end Get;
> 
>     task body T is
>        D : Integer;
>     begin
>        ID.Get (D);
>        ...
>     end T;
> 
> No discriminants.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Yes, for ID's.  I really dialed down the example
code for simplicity.  The actual scenario isn't 
ID's but a set of enumerations that provide
configuration data for the tasks.  They wouldn't
be unique or in any order.  I was mostly just seeing
if I could do away with the wrapper record for 
initialization.


  reply	other threads:[~2019-11-23 16:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 22:07 Initializing an array of tasks with discrimants Jere
2019-11-22 22:39 ` Jeffrey R. Carter
2019-11-23 16:23   ` Jere
2019-11-22 23:57 ` Robert A Duff
2019-11-23  0:27   ` Anh Vo
2019-11-23  9:12   ` Randy Brukardt
2019-11-23 16:50     ` Jere
2019-11-23 16:25   ` Jere
2019-11-23  8:29 ` Dmitry A. Kazakov
2019-11-23 16:28   ` Jere [this message]
2019-11-23 17:03     ` Dmitry A. Kazakov
2019-11-23 16:57 ` Jere
2019-11-25 22:36   ` Randy Brukardt
replies disabled

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