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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 10.66.249.202 with SMTP id yw10mr29029764pac.12.1421793380892; Tue, 20 Jan 2015 14:36:20 -0800 (PST) X-Received: by 10.140.31.134 with SMTP id f6mr45009qgf.33.1421793380843; Tue, 20 Jan 2015 14:36:20 -0800 (PST) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!h15no898029igd.0!news-out.google.com!l7ni1qai.0!nntp.google.com!v8no2435433qal.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 20 Jan 2015 14:36:20 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=80.223.109.117; posting-account=xMk30AoAAACEWgBjdZfjW9cEqRCtnf-j NNTP-Posting-Host: 80.223.109.117 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <32208488-3a04-4d2a-8c64-840502dcf96d@googlegroups.com> Subject: How to: communication between multiple tasks using protected objects - with no polling? From: Esa Riihonen Injection-Date: Tue, 20 Jan 2015 22:36:20 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:191958 Date: 2015-01-20T14:36:20-08:00 List-Id: I'm new to Ada and I have a problem ;) After reading through 'Programming in ADA 2012' by John Barnes - I decided = to try Ada in implementing the core functionality of a C-program I have bee= n involved recently. The C-program consists of various Linux processes that communicate with eac= h other mainly through FIFO's. It seems natural to implement the process fu= nctionality as Ada tasks. As the inter task communication I decided to try= protected types (instead of task entries). Here is the problem. My typical C-process 'listens' to several FIFOs connec= ted to separate processes. This is realized using a ppoll-type 'reactor' - = so in essence the process is sleeping until there is some activity in any o= f the monitored file descriptors (I guess this is in essence quite basic ar= rangement in the 'C-world'). I first thought I can implement this by the 'select' - something like this: PO1 and PO2 are instantiations of a protected type with entry 'Get'. ... loop ... select PO1.Get(...); or PO2.Get(...); or=20 ... end select; ... end loop; ... Alas, I quicky found out that 'or' is not allowed here between the protecte= d object entries. I can do something like this instead: ... loop ... select PO1.Get(...); else null; end select; select PO2.Get(...); else null; end select; ... end loop; ... But this would be now constantly polling in a loop. I would like the task t= o be suspended if there is nothing to do. I understand(?) that I probably c= ould achieve this by accepting task entries. But I wan't to know whether it= can be done using the protected objects for communication.=20 Am I missing something? Or have my though processes been totally corrupted = by too much (forced) C during the decades - and thus I'm trying to do somet= hing silly and dangerous?