comp.lang.ada
 help / color / mirror / Atom feed
From: Charles Hixson <charleshixsn@earthlink.net>
Subject: Re: asynchronous task communication
Date: Mon, 31 Dec 2012 10:52:22 -0800
Date: 2012-12-31T10:52:22-08:00	[thread overview]
Message-ID: <7NednS4s2oukfXzNnZ2dnUVZ_oadnZ2d@earthlink.com> (raw)
In-Reply-To: <50e18094$0$6583$9b4e6d93@newsspool3.arcor-online.net>

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;
>
>




  reply	other threads:[~2012-12-31 18:52 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-31  0:16 asynchronous task communication Charles Hixson
2012-12-31  9:04 ` Simon Wright
2012-12-31 11:49   ` Simon Wright
2012-12-31 10:50 ` J-P. Rosen
2012-12-31 12:09 ` Georg Bauhaus
2012-12-31 18:52   ` Charles Hixson [this message]
2012-12-31 20:18     ` Shark8
2012-12-31 21:09     ` Niklas Holsti
2012-12-31 22:15       ` Randy Brukardt
2013-01-01  3:58         ` Charles Hixson
2013-01-01  4:48           ` tmoran
2013-01-01 17:59             ` Charles Hixson
2013-01-01  3:51       ` Charles Hixson
2013-01-01  9:59         ` Dmitry A. Kazakov
2013-01-01 10:38         ` Brian Drummond
2013-01-01 12:32         ` Jeffrey Carter
2013-01-01 18:21           ` Charles Hixson
2013-01-01 18:54             ` Robert A Duff
2013-01-02  7:36               ` Charles Hixson
2013-01-02  9:55                 ` Dmitry A. Kazakov
2013-01-02 19:02                   ` Charles Hixson
2013-01-02 20:35                     ` Dmitry A. Kazakov
2013-01-03  0:20                       ` Charles Hixson
2013-01-03  6:34                         ` Charles Hixson
2013-01-03  8:50                         ` Dmitry A. Kazakov
2013-01-03 19:01                           ` Charles Hixson
2013-01-03 10:01                         ` J-P. Rosen
2013-01-03 19:29                           ` Charles Hixson
2013-01-04  8:17                             ` J-P. Rosen
2013-01-05  4:31                               ` Charles Hixson
2013-01-09  8:34                                 ` Stephen Leake
2013-01-03 22:27                         ` Randy Brukardt
2013-01-05  5:18                           ` Charles Hixson
2013-01-05  8:48                             ` Niklas Holsti
2013-01-06 22:55                               ` Charles Hixson
2013-01-07  0:38                                 ` tmoran
2013-01-07  6:07                                 ` Shark8
2013-01-07 10:49                                 ` Brian Drummond
2013-01-07 18:27                                   ` Jeffrey Carter
2013-01-08 12:02                                     ` Brian Drummond
2013-01-08 17:12                                       ` Jeffrey Carter
2013-01-08 18:18                                         ` Simon Wright
2013-01-08 20:29                                           ` Dmitry A. Kazakov
2013-01-08 21:01                                           ` Jeffrey Carter
2013-01-08 21:14                                             ` Simon Wright
2013-01-08 22:11                                               ` Randy Brukardt
2013-01-08 22:52                                               ` Jeffrey Carter
2013-01-08 22:26                                         ` Brian Drummond
2013-01-08  2:41                             ` Randy Brukardt
2013-01-02 22:43         ` Niklas Holsti
2013-01-03  1:30           ` Charles Hixson
2013-01-03 12:11             ` Georg Bauhaus
2013-01-03 13:17               ` Dmitry A. Kazakov
2013-01-05 20:19               ` Charles Hixson
2013-01-07  4:01                 ` Shark8
2013-01-01 19:59     ` J-P. Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox