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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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.0.170 with SMTP id 10mr1504261pbf.2.1321927092067; Mon, 21 Nov 2011 17:58:12 -0800 (PST) Path: lh20ni3563pbb.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: "Rego, P." Newsgroups: comp.lang.ada Subject: Re: Freezing a task Date: Mon, 21 Nov 2011 17:58:09 -0800 (PST) Organization: http://groups.google.com Message-ID: <19344963.18.1321927089210.JavaMail.geo-discussion-forums@yqni5> References: <32992849.648.1321544004241.JavaMail.geo-discussion-forums@vbmh5> Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 189.110.14.179 Mime-Version: 1.0 X-Trace: posting.google.com 1321927091 21559 127.0.0.1 (22 Nov 2011 01:58:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 22 Nov 2011 01:58:11 +0000 (UTC) Cc: anon@anon.org In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=189.110.14.179; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu User-Agent: G2/1.0 X-Google-Web-Client: true Xref: news2.google.com comp.lang.ada:14505 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-11-21T17:58:09-08:00 List-Id: > -- > -- Complete Program > -- > > with Text_IO ; > > procedure u is > > use Text_IO ; > > task type test is > entry Start ; -- initialize and start task > -- and task can die if parent stops > > entry Wait ; -- Send task to sleep for a while > -- and task can die if parent stops > > entry Continue ; -- wake up task > entry Stop ; -- stops and kill task > end test ; > > > task body test is > > Count : Integer ; > begin > -- Initialize task > Count := 0 ; > Outer_Loop : loop > select > -- start task > accept Start ; > Put_Line ( "Start" ) ; > > Main_Loop : loop > select > > -- pause task > accept Wait ; > Put_Line ( "Wait" ) ; > New_Line ; > > select > > -- sofware wake up task > accept Continue ; > Put_Line ( "Continue" ) ; > > -- software exit while in wait mode > or > accept Stop ; > Put_Line ( "Stop" ) ; > exit Outer_Loop ; > > -- exit if parent fails while in wait mode > or > terminate ; > end select ; > > -- software exit (abort) while in normal > -- execution mode > or > accept Stop ; > Put_Line ( "Stop" ) ; > exit Outer_Loop ; > > else > -- - - - - - - - - - - -- > -- Main Tasking Code -- > -- - - - - - - - - - - -- > Put ( "Testing" ) ; > Put ( Integer'Image ( Count ) ) ; > New_Line ; > Count := Count + 1 ; > end select ; > end loop Main_Loop ; > > -- exit if parent fails > or > terminate ; > end select ; > end loop Outer_Loop ; > Put_Line ( "Task has Terminated" ) ; > end test ; > > testing_task : test ; > > begin > Put_Line ( "Start Tasking" ) ; > New_Line ; > -- > testing_task.Start ; > delay ( 0.01 ) ; > testing_task.Wait ; > delay ( 1.0 ) ; > testing_task.Continue ; > delay ( 0.01 ) ; > testing_task.Wait ; > -- > delay ( 1.0 ) ; > testing_task.Stop ; > delay ( 0.5 ) ; > New_Line ; > end u ; I guess that's a very elegant way to implement it. Very thank you.