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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c07a147fda119dba X-Google-Attributes: gid103376,public From: nobody@REPLAY.COM (Anonymous) Subject: Re: Asynchronous communication between protected types Date: 1998/07/22 Message-ID: <199807221411.QAA20162@basement.replay.com>#1/1 X-Deja-AN: 373841751 Content-Transfer-Encoding: 7bit References: <6p2cvs$u2$1@client2.news.psi.net> Organization: Replay Associates, L.L.P. Mail-To-News-Contact: postmaster@nym.alias.net X-001: Replay may or may not approve of the content of this posting X-002: Report misuse of this automated service to X-URL: http://www.replay.com/remailer/ Content-Type: text/plain; charset=us-ascii Newsgroups: comp.lang.ada Date: 1998-07-22T00:00:00+00:00 List-Id: On 21 Jul 1998 15:43:56 GMT, james@sandy.mcci-arl-va.com (Scott James) wrote: > I'm trying to connect concurrent objects via an asynchronous > message. I was hoping to do this entirely with protected objects, > however, cannot seem to do so. The difficulty I have is that even if I > put the receiver into a loop (waiting on a send entry) it seems that > *some* task has to start the receiver, so I will still need one (Ada) > task per (active) receiver. > ... I assume that by "start the receiver", you mean call the initialize entry. Ada allows you to avoid that: with Ada.Text_IO; procedure Test_Persistent is type Messages is (Run, Die); protected type Persistent_Signals is procedure Send (Message: in Messages); entry Wait (Message: out Messages); private Message: Messages; Signal_Arrived: Boolean:=False; end Persistent_Signals; protected body Persistent_Signals is procedure Send (Message: in Messages) is begin Persistent_Signals.Message:=Message; Signal_Arrived:=True; end Send; entry Wait (Message: out messages) when Signal_Arrived is begin Signal_Arrived:=False; Message:=Persistent_Signals.Message; end Wait; end Persistent_Signals; task type Processes (Signal : access Persistent_Signals); task body Processes is Message: Messages; begin loop Signal.Wait (Message => Message); case Message is when Run => Ada.Text_IO.Put_Line ("I'm running"); when Die => exit; end case; end loop; end Processes; Signal : aliased Persistent_Signals; Process: Processes (Signal => Signal'access); begin for I in 1 .. 4 loop Signal.Send (Message => Run); delay 0.5; end loop; Signal.Send (Message => Die); end Test_Persistent; This compiles and runs fine on GNAT 3.10p1/Win95. Jeff Carter PGP:1024/440FBE21 My real e-mail address: ( carter @ innocon . com ) "I fart in your general direction." Monty Python & the Holy Grail Posted with Spam Hater - see http://www.compulink.co.uk/~net-services/spam/