🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.ada
Article #1018

Re: Need to see certain data inside a task type.

#1018
From: Doug Bryan
Date: Tue, 14 Oct 1986 20:52
58 lines
1839 bytes
Here is an idea for you... let me know if you get anything better.

doug
........................

generic
package Pack is
    task type T is
	entry My_Discriminant   (D : Integer);
	entry Echo_Discriminant;
    end T;
    type Acc is access T;
    function F (D : Integer) return Acc;
    type Rec (D : Integer) is
	record
	    Acc_T : Acc := F (D);
	end record;
end Pack;
-------------------------------

with Text_Io;
package body Pack is
    function F (D : Integer) return Acc is
	A : Acc := new T;
    begin
	A.My_Discriminant (D);
	return A;
    end F;

    task body T is
	Local_Discriminant : Integer;
    begin
	accept My_Discriminant (D : Integer) do
	    Local_Discriminant := D;
	end My_Discriminant;
	accept Echo_Discriminant;
	Text_Io.Put_Line (Integer'Image (Local_Discriminant));
    end T;
end Pack;
-------------------------------

with Pack;
procedure Disc_Task is
    package P is new Pack;

-- Pack is generic in order to force elaboration of body before
-- the following objects are elaborated.

    Rec_1 : P.Rec (1);
    Rec_2 : P.Rec (2);
    Rec_3 : P.Rec (3);
begin
    Rec_1.Acc_T.Echo_Discriminant;
    Rec_2.Acc_T.Echo_Discriminant;
    Rec_3.Acc_T.Echo_Discriminant;
end Disc_Task;

-------
Technical Details
Message-ID: <12246809238.39.BRYAN@Sierra.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!nike!ucbcad!ucbvax!SIERRA.STANFORD.EDU!Bryan

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!nike!ucbcad!ucbvax!SIERRA.STANFORD.EDU!Bryan
From: Bryan@SIERRA.STANFORD.EDU (Doug Bryan)
Newsgroups: net.lang.ada
Subject: Re: Need to see certain data inside a task type.
Message-ID: <12246809238.39.BRYAN@Sierra.Stanford.EDU>
Date: Tue, 14-Oct-86 16:52:23 EDT
Article-I.D.: Sierra.12246809238.39.BRYAN
Posted: Tue Oct 14 16:52:23 1986
Date-Received: Wed, 15-Oct-86 21:55:21 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The ARPA Internet
Lines: 58