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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,8e11100f675ea2df X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.77.34 with SMTP id p2mr10446473paw.30.1357498037678; Sun, 06 Jan 2013 10:47:17 -0800 (PST) Date: Mon, 31 Dec 2012 13:09:58 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: asynchronous task communication References: <1c2dnd5E6PMDR33NnZ2dnUVZ_sednZ2d@earthlink.com> In-Reply-To: <1c2dnd5E6PMDR33NnZ2dnUVZ_sednZ2d@earthlink.com> Message-ID: <50e18094$0$6583$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 31 Dec 2012 13:09:56 CET NNTP-Posting-Host: e2a32ace.newsspool3.arcor-online.net X-Trace: DXC=^?Fd;mn_Pn4gP]QSEBQ^d4McF=Q^Z^V384Fo<]lROoR18kFfN6PCY\c7>ejV8mB\dg On 31.12.12 01:16, Charles Hixson wrote: > > The only alternative that I've come up with is to have each task have an access variable to a protected type instance. This can be done, but it makes the control in other parts of the program trickier. You could make the letter actively deliver itself. Just in case you do no want to write a mail box, as suggested by J-P. Rosen. package Letters is task type Receiver is entry Knock (Message : String); end Receiver; task type Letter (Recipient : access constant Receiver) is entry Write (Message : String); end Letter; task type Sender is end Sender; end Letters; package body Letters is type Text_Buffer is access constant String; type Letter_Pointer is access Letter; Receiver_In_Scope : aliased Receiver; task body Receiver is begin accept Knock (Message : String); end Receiver; task body Letter is Text : Text_Buffer; begin -- get written, then actively get sent, then be finished accept Write (Message : String) do Letter.Text := new String'(Message); end Write; Recipient.Knock (Text.all); end Letter; task body Sender is procedure Send; -- prepare a self-delivering letter procedure Send is Order : Letter_Pointer; begin Order := new Letter (Recipient => Receiver_In_Scope'Access); Order.Write ("Meet me at 10 o'clock!"); end Send; begin null; -- ... Send; null; -- ... end Sender; end Letters;