Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!NOSC-TECR.ARPA!CONTR22
From: CONTR22@NOSC-TECR.ARPA.UUCP
Newsgroups: comp.lang.ada
Subject: passing a task type as a generic parameter
Message-ID: <8707072228.AA11262@ucbvax.Berkeley.EDU>
Date: Tue, 7-Jul-87 10:08:35 EDT
Article-I.D.: ucbvax.8707072228.AA11262
Posted: Tue Jul  7 10:08:35 1987
Date-Received: Fri, 10-Jul-87 03:24:59 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Distribution: world
Organization: The ARPA Internet
Lines: 59

Can anyone answer the following from my colleague, Jim Silver:

-- According to the LRM, we can pass a task type as the actual parameter
-- corresponding to Formal_Task_Type in the following generic procedure.

generic
    type Formal_Task_Type is limited private;
procedure Generic_Procedure
(
    Task_Object : Formal_Task_Type
);

procedure Generic_Procedure
(
    Task_Object : Formal_Task_Type
) is
begin

    -- Great, but what useful thing can we do with Task_Object here?
    -- In particular, is there any way to call an entry in Task_Object?

    null;
end Generic_Procedure;


with Generic_Procedure;
procedure User_Procedure is
    task type
        Actual_Task_Type is
            entry Entry_Point;
        end Actual_Task_Type;

    Task_Object_1 : Actual_Task_Type;
    Task_Object_2 : Actual_Task_Type;

    task body Actual_Task_Type is
    begin
        accept Entry_Point;
    end Actual_Task_Type;

    procedure Instantiated_Procedure is new Generic_Procedure(Actual_Task_Type);

begin
    -- Or, from the user's viewpoint, is there a mechanism which allows the
    -- first invocation below to call Task_Object_1.Entry_Point and the second
    -- to call Task_Object_2.Entry_Point?
    Instantiated_Procedure( Task_Object_1 );
    Instantiated_Procedure( Task_Object_2 );
end User_Procedure;

-- (I know that I can rewrite Generic_Procedure with a generic formal
-- procedure parameter then instantiate it twice, once with each entry
-- point, to get the same effect.  I would like to know if I can use task

Thanks.
Linda Rising
Magnavox
Ft. Wayne, IN
-- types to avoid this.)