From: "John G. Volan" <johnvolan@sprintmail.com>
Subject: Re: Task Discriminants & Arrays
Date: 1997/05/15
Date: 1997-05-15T00:00:00+00:00 [thread overview]
Message-ID: <337B09C9.62BB@sprintmail.com> (raw)
In-Reply-To: EA800I.Dv2@world.std.com
Robert A Duff wrote:
> I suppose
> you could have an array of tasks, and an array of pointers to tasks, and
> sort the latter (and hide the former from clients). The only advantage
> I can see to that is that it allows parallel activation of the tasks.
An interesting suggestion. We could have something like:
task type Process_Type
(Process_Id : Process_Id_Type := Get_New_Process_Id)
-- Note: We have to make sure this function is already
-- elaborated at this point; probably needs to be in another
-- package
is
...
end Process_Type;
type Process_Access_Type is access all Process_Type;
type Process_Array_Type is
array (Process_Index_Type range <>) of aliased Process_Type;
-- Note: Process_Index_Type does not necessarily have to be
-- the same as Process_Id_Type. In fact, they probably should
-- be different to avoid confusing the id of a process with its
-- arbitrary location in such an array, which won't necessarily
-- be the same.
type Process_Access_Array_Type is
array (Process_Id_Type range <>) of Process_Access_Type;
procedure Find_Process_Id_Bounds
(Process_Array : in Process_Array_Type;
Minimum_Process_Id : out Process_Id_Type;
Maximum_Process_Id : out Process_Id_Type)
is
...
begin
... -- left as an exercise for the reader
end Find_Process_Id_Bounds;
function Get_Process_Access_Array
(Process_Array : access Process_Array_Type)
return Process_Access_Array_Type
is
Minimum_Process_Id, Maximum_Process_Id : Process_Id_Type;
begin
Find_Process_Id_Bounds
(Process_Array.all, Minimum_Process_Id, Maximum_Process_Id);
declare
Process_Access_Array : Process_Access_Array_Type
(Minimum_Process_Id .. Maximum_Process_Id);
begin
for Process_Index in Process_Array'Range loop
declare
Process : constant Process_Access_Type :=
Process_Array(Process_Index)'Access;
begin
Process_Access_Array(Process.Process_Id) := Process;
end;
end loop;
return Process_Access_Array;
end;
end Get_Process_Access_Array;
And then in the client application code:
package Jeff_Carters_Million_Processes is
Process_Array : aliased Process_Array_Type (1 .. 1E6);
-- Wham!! ... all activated at once
Process_Access_Array : constant Process_Access_Array_Type :=
Get_Process_Access_Array (Process_Array'Access);
-- Deciding whether and how to hide either or both of these
-- arrays is left as an exercise for the reader.
end Jeff_Carters_Million_Processes;
:-) :-) :-)
------------------------------------------------------------------------
Internet.Usenet.Put_Signature
(Name => "John G. Volan", Home_Email => "johnvolan@sprintmail.com",
Slogan => "Ada95: The World's *FIRST* International-Standard OOPL",
Disclaimer => "These opinions were never defined, so using them " &
"would be erroneous...or is that just nondeterministic now? :-) ");
------------------------------------------------------------------------
next prev parent reply other threads:[~1997-05-15 0:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-05-13 0:00 Task Discriminants & Arrays Matthew Heaney
1997-05-13 0:00 ` Robert A Duff
1997-05-14 0:00 ` W. Wesley Groleau (Wes)
1997-05-15 0:00 ` Robert A Duff
1997-05-15 0:00 ` John G. Volan [this message]
1997-05-15 0:00 ` Matthew Heaney
1997-05-15 0:00 ` John G. Volan
1997-05-15 0:00 ` Robert A Duff
1997-05-16 0:00 ` John G. Volan
1997-05-16 0:00 ` John G. Volan
1997-05-15 0:00 ` Mats Weber
1997-05-13 0:00 ` Jeff Carter
1997-05-13 0:00 ` John G. Volan
1997-05-14 0:00 ` Jeff Carter
1997-05-13 0:00 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox