comp.lang.ada
 help / color / mirror / Atom feed
From: onox <denkpadje@gmail.com>
Subject: Re: 'Number_Of_CPUs' tasks creation, with discriminants, running simultaneously.
Date: Wed, 22 Jul 2020 12:05:01 -0700 (PDT)	[thread overview]
Message-ID: <7bbd54c2-38a2-483d-97d1-7984ec2ded9dn@googlegroups.com> (raw)
In-Reply-To: <3c8ea85b-501b-4489-bf85-e1f5567a14d4o@googlegroups.com>

On Monday, July 20, 2020 at 10:31:46 PM UTC+2, olivier...@gmail.com wrote:
> > The order of the discriminants is arbitrary; there is no guarantee that Worker (I) will have ID of I. Elaboration is sequential, so each Worker will have a unique ID.
> As long as all the tasks get a unique ID, I am fine. 
> 
> Function as a discriminant at elaboration ... should have thought about it but it looks like I am missing some wisdom points. 
> 
> Thank you Jeffrey.

Another way is to use an extended return:

spec:

   type Worker;

   task type Worker_Task (Data : not null access constant Worker);

   type Worker is limited record
      ID : Positive;
      T  : Worker_Task (Worker'Access);
   end record;

   type Worker_Array is array (Positive range <>) of Worker;

   function Make_Workers return Worker_Array;

body:

   function Make_Workers return Worker_Array is
   begin
      return Result : Worker_Array (1 .. Positive (Count)) do
         for Index in Result'Range loop
            Result (Index).ID := Index;
         end loop;
      end return;
   end Make_Workers;

   Workers : constant Worker_Array := Make_Workers;
   pragma Unreferenced (Workers);

      reply	other threads:[~2020-07-22 19:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 13:51 'Number_Of_CPUs' tasks creation, with discriminants, running simultaneously Olivier Henley
2020-07-20 13:55 ` Olivier Henley
2020-07-20 17:45 ` Jeffrey R. Carter
2020-07-20 20:31   ` Olivier Henley
2020-07-22 19:05     ` onox [this message]
replies disabled

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