comp.lang.ada
 help / color / mirror / Atom feed
* Q: Protected types and entries (long)
@ 1999-02-16  0:00 Erik Margraf
  1999-02-16  0:00 ` Wilhelm Spickermann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Erik Margraf @ 1999-02-16  0:00 UTC (permalink / 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
--------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-03-01  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-16  0:00 Q: Protected types and entries (long) Erik Margraf
1999-02-16  0:00 ` Wilhelm Spickermann
1999-02-19  0:00 ` Samuel Mize
1999-03-01  0:00 ` Robert A Duff

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