Article View: net.lang.ada
Article #1024Re: Need to see certain data inside a task type.
From: Bryan Doug Bryan
Date: Fri, 17 Oct 1986 21:10
Date: Fri, 17 Oct 1986 21:10
58 lines
1876 bytes
1876 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:
<344@ndmce.uucp>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!cuae2!ltuxa!we53!sw013b!dj3b1!killer!ndmce!pollux!infotel!ut-ngp!ut-sally!seismo!think!nike!ucbcad!ucbvax!SIERRA.STANFORD.EDU!BryanShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cuae2!ltuxa!we53!sw013b!dj3b1!killer!ndmce!pollux!infotel!ut-ngp!ut-sally!seismo!think!nike!ucbcad!ucbvax!SIERRA.STANFORD.EDU!Bryan From: Bryan@SIERRA.STANFORD.EDU@ndmce.uucp (Doug Bryan) Newsgroups: net.lang.ada Subject: Re: Need to see certain data inside a task type. Message-ID: <344@ndmce.uucp> Date: Fri, 17-Oct-86 17:10:44 EDT Article-I.D.: ndmce.344 Posted: Fri Oct 17 17:10:44 1986 Date-Received: Tue, 21-Oct-86 05:30:13 EDT Sender: news@ndmce.uucp Organization: The ARPA Internet Lines: 58