comp.lang.ada
 help / color / mirror / Atom feed
From: NiGHTS <nights@unku.us>
Subject: Re: Nested Task Entry Question
Date: Tue, 24 Apr 2018 15:00:48 -0700 (PDT)
Date: 2018-04-24T15:00:48-07:00	[thread overview]
Message-ID: <86979cc7-1e24-46af-9015-c19f4ec668c2@googlegroups.com> (raw)
In-Reply-To: <ece0d5d1-90a8-4b8e-bae3-4a2823f7a429@googlegroups.com>

On Tuesday, April 24, 2018 at 2:45:24 PM UTC-4, Shark8 wrote:
> On Tuesday, April 24, 2018 at 10:57:29 AM UTC-6, NiGHTS wrote:
> > I have two tasks: Task P and Task C. Task P creates Task C, but Task C must call entries into Task P. 
> > 
> > I can't seem to figure out how to make an entry on a parent task executable by a child task.
> > 
> > I am eternally grateful for your assistance! Thank you!
> 
>     Task Type Parent is
> 	Entry Start;
> 	Entry Child_Call( Value : Natural );
> 	Entry Stop;
>     End Parent;
>     
>     Task Type Child( P : not null access Parent ) is
>     End Child;
>     
>     Task Body Child is
>     Begin
> 	Ada.Text_IO.Put_Line( "Inside Child; Setting Parent value.");
> 	P.Child_Call( 23 );
>     End Child;
>     
>     Task Body Parent is
> 	Internal : Natural := 77;
>     Begin
> 	accept Start  do
> 	    Ada.Text_IO.Put_Line( "Starting Parent (Value:" &
> 			     Natural'Image(Internal) & " )." );
> 	end Start;
> 	accept Child_Call (Value : in Natural) do
> 	    Ada.Text_IO.Put_Line( "Call from child." );
> 	    Internal := Value;
> 	end Child_Call;
> 	accept Stop  do
> 	    Ada.Text_IO.Put_Line( "Stopping Parent (Value:" &
> 			     Natural'Image(Internal) & " )." );
> 	end Stop;
>     End Parent;
> 
> --...
>     Parent_Task.Start;
>     -- Hidden Child call happens after Start finishes, due to being queued on entry.
>     Parent_Task.Stop;
> 
> ----------------
> Also, note that the putline happens *BEFORE* the output of the Parent-task; this is because the queuing on the entry happens, due to the parent having to wait for the START entry.

My guess is that you meant to instantiate the child task type into the parent declaration area, though forgot to do that. Still I see your point. Thank you for your help.

  reply	other threads:[~2018-04-24 22:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 16:57 Nested Task Entry Question NiGHTS
2018-04-24 18:45 ` Shark8
2018-04-24 22:00   ` NiGHTS [this message]
2018-04-24 20:47 ` AdaMagica
2018-04-24 20:54   ` AdaMagica
2018-04-24 22:03   ` NiGHTS
replies disabled

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