comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: task model
Date: Thu, 15 Oct 2009 21:54:27 +0200
Date: 2009-10-15T21:54:23+02:00	[thread overview]
Message-ID: <nahsigbubftd.6s9bknzww2a4$.dlg@40tude.net> (raw)
In-Reply-To: 6b6bd661-06b0-4ef6-8d48-0ef97d55fdd4@f20g2000prn.googlegroups.com

On Thu, 15 Oct 2009 12:15:56 -0700 (PDT), Anh Vo wrote:

> I would like to expand Ludovic's comment.
> 
> You have a couple of options to improve it.
> 
> 1. Make sure the task not terminated before calling its entry. That is
> using proc1'terminated syntax to query it.
> 2. Add infinite loop enclosing accept statements. So, entry call can
> be served always. This makes tasks alive even after the program ends
> (program will hang) unless Ctrl-C or other mean to end it. The clean
> solution is add entry Shutdown to the task. When this entry is
> invoked, just exit the loop. Thus, the task will terminate cleanly.

2'. In order to terminate a task upon parent's completion use select
statement with a terminate alternative:

select
   accept XYZ;
or terminate; -- Ends the task when the parent terminates
end select;

(Shutdown entry is used when terminate is not allowed, e.g. when a delay
alternative or else part is present in the select, or when some explicit
completion code need to be executed, however any local objects are properly
finalized when the terminate alternative is accepted.)

3. Do not do any asynchronous (lengthy) processing within a rendezvous,
i.e. within do...end of an accept. During the rendezvous the caller is
blocked. Rendezvous is meant for short synchronous things, like passing the
parameters and results, then the caller is released and the callee
completes things asynchronously to the caller.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2009-10-15 19:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-15 17:43 task model Mike
2009-10-15 18:00 ` Ludovic Brenta
2009-10-15 19:15   ` Anh Vo
2009-10-15 19:54     ` Dmitry A. Kazakov [this message]
2009-10-15 20:15       ` Jeffrey R. Carter
2009-10-16 14:06       ` Georg Bauhaus
2009-10-16 14:57         ` Brad Moore
2009-10-16 20:06         ` Jeffrey R. Carter
2009-10-17 11:10           ` Georg Bauhaus
2009-10-17 12:18             ` Dmitry A. Kazakov
2009-10-17 17:34             ` Jeffrey R. Carter
2009-10-19  7:56         ` Jean-Pierre Rosen
2009-10-15 19:55     ` sjw
replies disabled

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