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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7897733b1978b6a4 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.28.135 with SMTP id b7mr351469pbh.8.1321548822818; Thu, 17 Nov 2011 08:53:42 -0800 (PST) Path: h5ni2023pba.0!nntp.google.com!news1.google.com!news.glorb.com!feeder.erje.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Freezing a task Date: Thu, 17 Nov 2011 17:53:42 +0100 Organization: cbb software GmbH Message-ID: <1mvy349lkn3wg$.1dxam3tmlwr6l$.dlg@40tude.net> References: <32992849.648.1321544004241.JavaMail.geo-discussion-forums@vbmh5> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: uj8eDODkXPBoTj2NquW7bg.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news1.google.com comp.lang.ada:18951 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-11-17T17:53:42+01:00 List-Id: On Thu, 17 Nov 2011 17:22:57 +0100, Dmitry A. Kazakov wrote: > Paused : Boolean := False; > begin > loop > if Paused then > accept Release; > Paused := False; > else > select > accept Pause; > Paused := True; > else > ... -- Do stuff > end select; > end if; > end loop; P.S. there is a deadlock in above if improperly used from outside. It is simple to fix. It is worth to note that one of the rationales behind protected objects introduced in Ada 95, was to ease things like above. The same done with a protected object would be simpler, safer and reusable (within the task) too. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de