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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA 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.35.68 with SMTP id f4mr703672pbj.5.1321596297775; Thu, 17 Nov 2011 22:04:57 -0800 (PST) Path: h5ni4321pba.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Freezing a task Date: Thu, 17 Nov 2011 23:04:54 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <32992849.648.1321544004241.JavaMail.geo-discussion-forums@vbmh5> <32201299.75.1321579435782.JavaMail.geo-discussion-forums@yqbl36> NNTP-Posting-Host: f82b58caa918cb4eb83d26f9e2f82d58 Mime-Version: 1.0 X-Trace: e081e88be2872f1c79436e6a54a4b0e9 X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: <32201299.75.1321579435782.JavaMail.geo-discussion-forums@yqbl36> X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=e081e88be2872f1c79436e6a54a4b0e9 X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: news1.google.com comp.lang.ada:18963 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-11-17T23:04:54-07:00 List-Id: On 11/17/2011 06:23 PM, Rego, P. wrote: > > So I can use > > Paused : Boolean := False; > begin > accept Start; > loop > if Paused then > accept Release; > Paused := False; > else > select > accept Pause; > Paused := True; > else > ... -- Do stuff > end select; > end if; > end loop; > > and if I would want to add an abort entry? What should I do? Depends on when you want to be able to stop the task. I'd guess select accept Pause; Paused := True; or accept Stop; exit; else -- Do stuff. end select; "abort" is a reserved word, so it can't be the name of the entry. A protected object seems cleaner, though: protected Control is procedure Process; -- Instruct the task to start processing, or to resume processing after -- being paused. procedure Stop; -- Tell the task to terminate. procedure Pause; -- Tell the task to pause processing. entry Get (Stop : out Boolean); -- Used by the task to wait until it should do something. -- Stop will be True if the task should terminate; False if it should -- do stuff. private -- Control ... end Control; task body T is Stop : Boolean; begin -- T loop Control.Get (Stop => Stop); exit when Stop; -- Do stuff. end loop; end T; -- Jeff Carter "You can never forget too much about C++." 115