comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Buffer PO
Date: Fri, 3 Jun 2016 10:48:02 -0700
Date: 2016-06-03T10:48:02-07:00	[thread overview]
Message-ID: <nisfsi$o75$1@dont-email.me> (raw)
In-Reply-To: <1bc41b66-8dd4-4b4e-903e-f314babc07f9@googlegroups.com>

On 06/03/2016 06:29 AM, tonyg wrote:
> 
> I have a Fifo buffer in a protect object with a push / pop procedures and an is_empty function storing a gaggle of variant records.
> 
> I push just fine but when I come to collect my data with a pop, I have to assign it to a variable which is predeclared.
> 
> I cannot use a function as this cannot change the inside of a protected object.
> 
> Now I could use an extra buffer to contain the variant record discriminator but is there a better way?
> 
> I did think of adding a function to peek at the discriminator, but this could cause a problem as a push may change the record being viewed before my pop.

So the element type is discriminated? If the type has a default for the
discriminants, then the variable that obtains the value can be unconstrained.

If you're using Ada 12, you can use a synchronized queue rather than rolling
your own (ARM A.18.28-29). If not, the PragmAda Reusable Components have a
collection of protected queues.

-- 
Jeff Carter
"To Err is human, to really screw up, you need C++!"
Stéphane Richard
63

  parent reply	other threads:[~2016-06-03 17:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03 13:29 Buffer PO tonyg
2016-06-03 15:35 ` Anh Vo
2016-06-03 16:20 ` Mark Lorenzen
2016-06-03 17:48 ` Jeffrey R. Carter [this message]
2016-06-03 19:10 ` Dmitry A. Kazakov
2016-06-04 11:49 ` tonyg
replies disabled

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