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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx03.iad.POSTED!not-for-mail From: Hubert User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to: communication between multiple tasks using protected objects - with no polling? References: <32208488-3a04-4d2a-8c64-840502dcf96d@googlegroups.com> In-Reply-To: <32208488-3a04-4d2a-8c64-840502dcf96d@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 150120-1, 01/20/2015), Outbound message X-Antivirus-Status: Clean Message-ID: X-Complaints-To: abuse@newsdemon.com NNTP-Posting-Date: Wed, 21 Jan 2015 00:19:42 UTC Organization: http://www.NewsDemon.com Date: Tue, 20 Jan 2015 16:19:44 -0800 X-Received-Bytes: 2150 X-Received-Body-CRC: 182750363 Xref: news.eternal-september.org comp.lang.ada:24655 Date: 2015-01-20T16:19:44-08:00 List-Id: Hey, I'm new to Ada as well and I was facing the same problem in my application. I have to wait for input from TCP sockets as well as input from the user. It is true that the Select statement, when calling a protected type entry or procedure can be used only for one such call. It is not possible to wait for multiple protected object entries. So my solution was to have one protected object that serves as a form of event buffer. Any section of my code that needs to communicate with the task, writes an event into the PO. The task then waits for an event in the PO. the PO provides these events through an entry with a barrier that is something like "WHEN LENGTH( Event_Queue) > 0". You can then also use a timed select statement like so: SELECT Wait_For_Event( PO ); OR Delay 1.0; END SELECT which will time out after 1 second and allow your task to do something else before entering the select statement again in a loop. For instance you could check for a task entry that commands your task to halt and exit, if you want to delete the task or shut down the program --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com