From: Simon Wright <simon@pushface.org>
Subject: Re: How to: communication between multiple tasks using protected objects - with no polling?
Date: Wed, 21 Jan 2015 08:11:32 +0000
Date: 2015-01-21T08:11:32+00:00 [thread overview]
Message-ID: <lyd268o8nf.fsf@pushface.org> (raw)
In-Reply-To: m9msu0$hja$2@dont-email.me
Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:
> Another approach might be
>
> type Q_ID is (Q1, Q2, ...);
>
> type Q_Item (Q : Q_ID := Q_ID'First) is record
> case Q is
> when Q1 =>
> Item_1 : Q1_Item;
> when Q2 =>
> Item_2 : Q2:Item;
> ...
> end case;
> end record;
>
> protected Qs is
> entry Get (Item : out Q_Item);
> private -- Qs
> Q_1 : Q1_Q;
> Q_2 : Q2_Q;
> ...
> end Qs;
>
> protected body Qs is
> entry Get (Item : out Q_Item) when
> not Q_1.Is_Empty or not Q_2.Is_Empty or ...
> is
> -- Empty declarative part
> begin -- Get
> if not Q_1.Is_Empty then
> Item := (Q => Q1, Item_1 => Q_1.Get);
> elsif not Q_2.Is_Empty then
> item := (Q => Q2, Item_2 => Q_2.Get;
> ...
> end if;
> end Get;
> end Qs;
Yet another approach: make Q_Item an abstract tagged type with an
abstract Handle operation. You'd need the actual queue inside the PO to
be of Q_Item'Class (or perhaps an access to such, in which case you'd
need to do your own deallocation).
next prev parent reply other threads:[~2015-01-21 8:11 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
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 [this message]
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