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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b4731a3b5d591abd X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Task Discriminants & Arrays Date: 1997/05/15 Message-ID: <337B09C9.62BB@sprintmail.com>#1/1 X-Deja-AN: 241679079 References: <3379C86F.352@this.message> Organization: Sprint Internet Passport Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-05-15T00:00:00+00:00 List-Id: 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? :-) "); ------------------------------------------------------------------------