comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: can someone help me with this code (explanation)
Date: Wed, 8 Oct 2014 21:45:01 -0500
Date: 2014-10-08T21:45:01-05:00	[thread overview]
Message-ID: <m14sre$lab$1@loke.gir.dk> (raw)
In-Reply-To: c8ljhpFaqrfU4@mid.individual.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:c8ljhpFaqrfU4@mid.individual.net...
> On 14-09-26 10:58 , J-P. Rosen wrote:
>> Le 26/09/2014 09:04, Björn Lundin a écrit :
>>> Or by using a protected object as a semaphore
>>>
>> But why? It's so simpler with a task:
>>
>>    task Printer is
>>       entry Print (Mess : String);
>>    end Printer;
>
> The semaphore solution lets one group related output lines together; the
> task+entry (in the above form) can interleave output lines from
> different tasks, perhaps making output harder to read. Whether this
> matters depends on what one needs.

Right. Note that the semaphore ought to be wrapped in a Limited_Controlled 
object so that it gets unlocked if the scope is exited by an exception. 
That's especially important for protecting I/O, since I/O routines have a 
tendency to propagate an exception because of full disks, permissions 
errors, etc. Without such protection, an exception would leave the semaphore 
locked and you'll end up with deadlock as no task can do any I/O. (The task 
version probably ought to be protected from exceptions as well, I'll leave 
that as an exercise for the reader.)

                            Randy.


  reply	other threads:[~2014-10-09  2:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-25 13:44 can someone help me with this code (explanation) Stribor40
2014-09-25 14:56 ` Björn Lundin
2014-09-25 15:01   ` Björn Lundin
2014-09-25 15:54   ` Stribor40
2014-09-25 17:11     ` Niklas Holsti
2014-09-25 19:41       ` Stribor40
2014-09-25 19:53         ` Jeffrey Carter
2014-09-25 20:10         ` Niklas Holsti
2014-09-25 22:27           ` Jeffrey Carter
2014-09-26  7:04             ` Björn Lundin
2014-09-26  7:58               ` J-P. Rosen
2014-09-26 10:24                 ` G.B.
2014-09-26 11:48                 ` Björn Lundin
2014-09-26 12:49                   ` J-P. Rosen
2014-09-26 14:15                     ` Björn Lundin
2014-09-26 14:49                       ` J-P. Rosen
2014-09-26 15:31                         ` Björn Lundin
2014-09-26 16:08                           ` G.B.
2014-09-30  4:22                             ` Brad Moore
2014-09-30 21:59                               ` Georg Bauhaus
2014-10-01 15:38                                 ` Brad Moore
2014-09-26 16:23                           ` Dmitry A. Kazakov
2014-09-26 20:38                           ` J-P. Rosen
2014-09-27 18:16                             ` Björn Lundin
2014-09-26 16:43                       ` Niklas Holsti
2014-09-26 16:45                 ` Niklas Holsti
2014-10-09  2:45                   ` Randy Brukardt [this message]
2014-09-26 16:44             ` Niklas Holsti
2014-09-26  5:06           ` J-P. Rosen
2014-09-25 16:53 ` Jeffrey Carter
replies disabled

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