comp.lang.ada
 help / color / mirror / Atom feed
From: Hubert <herrdoktor@fumanchu.com>
Subject: Re: How to: communication between multiple tasks using protected objects - with no polling?
Date: Tue, 20 Jan 2015 16:19:44 -0800
Date: 2015-01-20T16:19:44-08:00	[thread overview]
Message-ID: <ygCvw.930507$Hb3.567654@fx03.iad> (raw)
In-Reply-To: <32208488-3a04-4d2a-8c64-840502dcf96d@googlegroups.com>

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

  reply	other threads:[~2015-01-21  0:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 22:36 How to: communication between multiple tasks using protected objects - with no polling? Esa Riihonen
2015-01-21  0:19 ` Hubert [this message]
2015-01-21 16:53   ` Esa Riihonen
2015-01-21 23:22     ` Hubert
2015-01-22 13:24       ` Esa Riihonen
2015-01-21  0:47 ` Jeffrey Carter
2015-01-21  8:11   ` Simon Wright
2015-01-21 17:16   ` Esa Riihonen
2015-01-21 18:39     ` Jeffrey Carter
2015-01-22 13:32       ` Esa Riihonen
2015-01-21  8:28 ` Dmitry A. Kazakov
2015-01-21 17:34   ` Esa Riihonen
2015-01-21 18:56     ` Jacob Sparre Andersen
2015-01-21 20:15       ` Dmitry A. Kazakov
2015-01-22 21:52         ` G.B.
2015-01-23  8:25           ` Dmitry A. Kazakov
2015-01-21 20:02     ` Dmitry A. Kazakov
2015-01-22 13:37       ` Esa Riihonen
replies disabled

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