comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Composing tasks and protected objects
Date: Sat, 6 Aug 2005 11:01:51 +0200
Date: 2005-08-06T11:01:49+02:00	[thread overview]
Message-ID: <y6xqs0bkj9zo$.mowuzl9xig6f$.dlg@40tude.net> (raw)
In-Reply-To: 87iryk1eic.fsf@mid.deneb.enyo.de

On Fri, 05 Aug 2005 19:26:35 +0200, Florian Weimer wrote:

> Suppose I want to write a selective accept which reads messages from a
> queue, and also support a special entry call to reload the
> configuration.
> 
> Conceptually, this would look like this:
> 
>    task Server is
>       entry Reload_Configuration (Config : Config_Template);
>       entry Shut_DOwn;
>    end Server;
> 
>    task body Server is
>       Current_Message : Message;
> 
>    begin
>       loop
>          select
>             Get (Queue, Current_Message);
>             Process_Message (Current_Message);
> 
>          or
>             accept Reload_Configuration (Config : Config_Template) do
>                Process_Reload (Config);
>             end Reload_Configuration;
> 
>          or
>             accept Shut_Down;
>             exit;       -- Premature shut down requested
> 
>          or
>             terminate;  -- Normal shutdown at end of scope
>          end select;
>       end loop;
>    end Server;

You could make "Reload_Configuration" and "Shut_Down" messages rather than
entries. Of course only if you don't need to wait for their completion.
Otherwise you are going to mix synchronous calls with fire-and-forget
messaging. It is always difficult.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



      parent reply	other threads:[~2005-08-06  9:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-05 17:26 Composing tasks and protected objects Florian Weimer
2005-08-05 17:49 ` Robert A Duff
2005-08-05 18:09   ` Florian Weimer
2005-08-05 18:26     ` Robert A Duff
2005-08-05 19:20       ` Florian Weimer
2005-08-07  1:27       ` Randy Brukardt
2005-08-08 21:55         ` Robert A Duff
2005-08-06  5:52 ` Jeffrey Carter
2005-08-08  9:52   ` Florian Weimer
2005-08-08 20:50     ` Randy Brukardt
2005-08-08 22:14       ` Robert A Duff
2005-08-06  9:01 ` Dmitry A. Kazakov [this message]
replies disabled

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