comp.lang.ada
 help / color / mirror / Atom feed
From: Erik Margraf <erik.margraf@siemens.at>
Subject: Q: Protected types and entries (long)
Date: 1999/02/16
Date: 1999-02-16T14:33:17+00:00	[thread overview]
Message-ID: <36C98180.98296205@siemens.at> (raw)

Recently I started to learn about protected types. I tried to do 
something like the following:

(Not 100% Ada :-)

...
   type buffer is array (...) of character;
   protected type Object is
     entry put (data : in buffer);
   private
     internal_buffer : array (BIG_Enough) of character;
     items_in_buffer : integer := 0;
   end; 
...
   protected Object body

   entry put (data : in buffer) 
	when data'size + items_in_buffer <= internal_buffer´size is
   begin
    ...
   end;
   end Object;

Since the reference to a formal parameter of an entry is not allowed,
gnat
refused to compile this ;-). I changed the code to

   type buffer is array (...) of character;
   protected type Object is
     entry put (data : in buffer);
   private
     entry p_put (data : in buffer);
     internal_buffer : array (BIG_Enough) of character;
     data_size : integer;
     items_in_buffer : integer := 0;
   end; 
...
   protected Object body
   entry put (data : in buffer) 
	when true is
   begin
      data_size := data´size;
      if data_size + items_in_buffer > internal_buffer´size then 
        requeue p_put;
      end if;
   end;

   entry p_put (data : in buffer) 
	when data_size + items_in_buffer <= internal_buffer´size is
   begin
    ...
   end;
   end Object;

This compiles. 
Now my questions:

	- Can someone tell me WHY this limitation in the barrier exists?
	- Is my "solution" really a solution to this problem?
	- (What) Should I do something different?
Thanks

Erik Margraf

-- 
--------------------------------------------------------------------
-- Erik Margraf
-- Siemens Austria PSE KB2
-- erik.margraf@siemens.at
-- +43 1 1707 45887
--------------------------------------------------------------------




             reply	other threads:[~1999-02-16  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-16  0:00 Erik Margraf [this message]
1999-02-16  0:00 ` Q: Protected types and entries (long) Wilhelm Spickermann
1999-02-19  0:00 ` Samuel Mize
1999-03-01  0:00 ` Robert A Duff
replies disabled

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