From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c3c4ae45442f569e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!newsfeed.stueberl.de!feed.news.tiscali.de!darth-vader.mobilixnet.dk!newsfeed.orangenet.dk!news.hacking.dk!pnx.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: [newbie question] tasks and protected types Date: 29 Apr 2005 13:23:10 +0200 Organization: hacking.dk - Doing fun stuff with open source Message-ID: References: <1114747457.868019.93210@f14g2000cwb.googlegroups.com> <42720DCD.6030304@mailinator.com> NNTP-Posting-Host: 80.241.165.42 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: xyzzy.adsl.dk 1114774066 3700 80.241.165.42 (29 Apr 2005 11:27:46 GMT) X-Complaints-To: usenet@news.hacking.dk NNTP-Posting-Date: Fri, 29 Apr 2005 11:27:46 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Xref: g2news1.google.com comp.lang.ada:10812 Date: 2005-04-29T13:23:10+02:00 List-Id: Alex R. Mosteo wrote: > Jacob Sparre Andersen wrote: > > protected body Printer is > > procedure Put_Line (Item : in String) is > > begin > > Ada.Text_IO.Put_Line (Item => Item); > > Ada.Text_IO.Flush; > > end Put_Line; > > end Printer; > > Isn't this considered a blocking operation? I think I have heard something like that too, but I have not been able to find it written down anywhere. > I've read that it is not something to avoid in practice, but this > advice can be specific for GNAT. I only tested my version with GNAT, so I can't disprove that. If calls to Ada.Text_IO _are_ potentially blocking operations, that means that one has to move the calls to a task. But from a logical point of view, using a protected object seems like the right way to do it. Jacob -- A password should be like a toothbrush. Use it every day; change it regularly; and DON'T share it with friends.