comp.lang.ada
 help / color / mirror / Atom feed
From: "Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr>
Subject: Re: Neater entry point code
Date: 1997/12/18
Date: 1997-12-18T00:00:00+00:00	[thread overview]
Message-ID: <67b0e3$qdo$1@peuplier.wanadoo.fr> (raw)
In-Reply-To: 34989E2A.93EF7271@dsto.defence.gov.au

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]


Mark Rutten a �crit dans le message
<34989E2A.93EF7271@dsto.defence.gov.au>...
>
>
>The code that I have at the moment looks like
>
>    while Execute'Count /= 0 loop
>
>      accept Execute( In_Msg: in Message_Typ ) do
>        Msg := In_Msg;
>      end Execute;
>
>      Add_Msg(Msg);
>
>    end loop;
>
>    Execute_Stuff;
>
>
>What I'm trying to do is extract anything that's queued up
>on the entry point and then go off and do something else.
>
>Is there a neater way of doing this? I don't want to use another
>task to do either Add_Msg or Execute_Stuff.
As Ben pointed out, the 'Count attribute is not the proper way to do this,
although you can find examples of it in some very famous books about Ada
tasking... It is surprising to see how often people write this, while there
is a perfect way of checking if a rendezvous can be accepted: an else part
in a select statement. Your code should be:

    loop

      select
         accept Execute( In_Msg: in Message_Typ ) do
           Msg := In_Msg;
         end Execute;
         Add_Msg(Msg);
      else
           exit;
       end select;


    end loop;

    Execute_Stuff;







  parent reply	other threads:[~1997-12-18  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-12-18  0:00 Neater entry point code Mark Rutten
1997-12-17  0:00 ` Matthew Heaney
1997-12-18  0:00 ` Jean-Pierre Rosen [this message]
1997-12-18  0:00 ` Ben Brosgol
replies disabled

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