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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,13c68a067434682 X-Google-Attributes: gid103376,public From: balmacara9@aol.com (Balmacara9) Subject: Re: Task question Date: 1997/10/30 Message-ID: <19971030040501.XAA24250@ladder02.news.aol.com>#1/1 X-Deja-AN: 286697911 References: <3439D647.7C43@home.com> X-Admin: news@aol.com Organization: AOL http://www.aol.com Newsgroups: comp.lang.ada Date: 1997-10-30T00:00:00+00:00 List-Id: >Subject: Task question >From: Larry Coon >Date: Tue, Oct 7, 1997 02:27 EDT >Message-id: <3439D647.7C43@home.com> > >I'm having a problem getting a task body to work >the way I want it to. Here's a contrived example >showing (with illegal syntax) what I want to do: > >task body x is >begin > loop > select > accept my_rendezvous (some_data: some_data_type) do > -- Rendezvous stuff > end my_rendezvous; > or > exit; -- This is illegal > end select; > end loop; > -- Now do more stuff. >end x; > >The idea is that this task serves as a collector. >Another task continually initiates rendezvous (what >is plural for rendezvous?), with this task, and this >tasks collects the information that is sent. When the >"calling" task is done it terminates. Since the select >statement is smart, it knows it can't be called any >more and invokes the exit, which terminates the loop >so the rest of the task body executes, and it does >more stuff. That's how I want it to work, anyway. > >If I do: > > or > terminate; > >in place of the exit then it knows when the "calling" >task is done and will terminate the task, but this isn't >what I want -- the "other stuff" never gets executed. > >I've also tried adding another accept as a signal for >when the "calling" task is done: > >task body x is >begin > loop > select > accept my_rendezvous (some_data: some_data_type) do > -- Rendezvous stuff > end my_rendezvous; > or > accept done do > exit; > end done; > end select; > end loop; > -- Now do more stuff. >end x; > >Now the "calling" task keeps initiating a my_rendezvous, >but when it's finished it inititates a done to let this >task know it can proceed. This doesn't work either -- it >doesn't let an exit transfer control out of the accept >statement. > >Am I missing an obvious way to do what I want? > >Larry Coon >University of California >larry@fs2.assist.uci.edu >and lmcoom@home.com > > > > > > > Just change your task like so.... task body x is begin loop select accept my_rendezvous (some_data: some_data_type) do -- Rendezvous stuff end my_rendezvous; or accept done; exit; end select; end loop; -- Now do more stuff. end x; You do not have to do all your work during the rendezvous, you can use the rendevous for pure synchronization and then perform the work after the rendezvous. Between the "do" and "end" of a rendezvous, the calling task is blocked so you must release the calling task before exiting the loop.