comp.lang.ada
 help / color / mirror / Atom feed
From: Bryan@SIERRA.STANFORD.EDU@ndmce.uucp (Doug Bryan)
Subject: Re: Need to see certain data inside a task type.
Date: Fri, 17-Oct-86 17:10:44 EDT	[thread overview]
Date: Fri Oct 17 17:10:44 1986
Message-ID: <344@ndmce.uucp> (raw)

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;

-------

             reply	other threads:[~1986-10-17 21:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1986-10-17 21:10 Bryan [this message]
  -- strict thread matches above, loose matches on Subject: below --
1986-10-17 21:06 Need to see certain data inside a task type gary
1986-10-14 21:39 Gary Dismukes @lizard
1986-10-14 20:52 Doug Bryan
1986-10-13 14:09 "LEN ARMSTRONG ", SYSTEMS LAB
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox