comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Protected types made of ADT's, and Passive Iterators
Date: 1998/09/05
Date: 1998-09-05T00:00:00+00:00	[thread overview]
Message-ID: <m3btou4urs.fsf@mheaney.ni.net> (raw)
In-Reply-To: udpvdbl8uf.fsf@tanana.llnl.gov

woodruff@tanana.llnl.gov (John Woodruff) writes:

> Any advice that will make the full facility of passive iterator
> available in the task-safe environment?

Can you give me a qualitative description of your problem?  

What's wrong with this:

generic
   with procedure Process 
      (Item : in out Collection_Item;
       Quit : in out Boolean);
procedure Modify_Items (Collection : in out Collection_Type);


procedure Modify_Items (Collection : in out Collection_Type) is

   Quit : Boolean := False;
   List : List_Type;
begin

   Seize (Collection.Guard);

   List := Collection.List;

   for Index in Positive range 1 .. Collection.Number_Of_Items loop

      Process (List.Item, Quit);

      exit when Quit;

      List := List.Next;

   end loop;

   Release (Collection.Guard);

end Modify_Items;


I noticed you used a list.  Be careful.  I list is a polylithic
structure, which is made for structure sharing.  Are you sure you don't
want a monolithic component (like a collection, or queue, etc)?

Your question "How do I make a list task safe?" is a little like asking
"What is the sound of one hand clapping?"  The question itself is all
wrong, because of an "abstraction-level mismatch."

Typically, you use a list to implement a container, you don't use a list
directly.  Make the monolithic container abstraction task safe, not a
list abstraction.




  reply	other threads:[~1998-09-05  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-04  0:00 Protected types made of ADT's, and Passive Iterators John Woodruff
1998-09-05  0:00 ` Matthew Heaney [this message]
1998-09-05  0:00   ` Tom Moran
1998-09-07  0:00   ` Mats Weber
1998-09-17  0:00     ` Matthew Heaney
1998-09-05  0:00 ` Tom Moran
1998-09-07  0:00 ` Mats Weber
replies disabled

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