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: 103376,8e11100f675ea2df X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.80.199 with SMTP id t7mr7407437pax.40.1356980282190; Mon, 31 Dec 2012 10:58:02 -0800 (PST) Path: 6ni74566pbd.1!nntp.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 31 Dec 2012 12:58:01 -0600 Date: Mon, 31 Dec 2012 10:52:22 -0800 From: Charles Hixson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: asynchronous task communication References: <1c2dnd5E6PMDR33NnZ2dnUVZ_sednZ2d@earthlink.com> <50e18094$0$6583$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: <50e18094$0$6583$9b4e6d93@newsspool3.arcor-online.net> Message-ID: <7NednS4s2oukfXzNnZ2dnUVZ_oadnZ2d@earthlink.com> X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 216.244.16.210 X-Trace: sv3-rokZLNZTgVzbMRFfdbk3E5HEySuOA+RlBQfHJnYgtHSsHAjhWHaYa9ngM3eIYSj3lgFQAx4Xx1fLAT5!A978kYKZW0b1zgenjM84xzKMVuwkjMYu/vKrQDY1hMyEcrg6xGY1UPj23w9DuLPThe0v5DZ+9Pmj!FQ8SNuQZjoHdxx5Kygon4g== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 4098 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-12-31T10:52:22-08:00 List-Id: Thank you for your answer. The problem with that solution is that I've been advised that I shouldn't have many more tasks than available cores, and that uses 2 of my available 6. True, several clients could use the same postmaster, but it's still too resource intensive. It's looking more and more like protected objects on the heap are the best answer. I just wasn't sure that a built-in answer didn't exist. (FWIW, I think I could get away with reducing the postmaster to only using one thread, but that's still too resource intensive. Actually, I'll probably redesign your postmaster to be a single protected object on the heap, as storing a message shouldn't block for long, and reading a message should be even less limiting. I'd go with messages to individual protected objects, but there's a feed-back interaction that would cause everything to lock up.) OTOH, actual non-blocking (i.e. asynchronous) calls to either threads or protected items is what I really need. These other things are make-shift kludges. They centralize control that should be distributed. But since the called item will want to send a message back (and possibly onwards)...everything freezes up unless the message sending is asynchronous. On 12/31/2012 04:09 AM, Georg Bauhaus wrote: > 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; > >