swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Birth/Death


From: Roger M. Burkhart
Subject: Re: Birth/Death
Date: Tue, 12 Nov 1996 16:41:42 -0600

On modifying the contents of a Swarm while it is executing, Chris Langton
wrote:

> Glen's caution is well taken - It is likely that the
> model swarm is in the act of iterating over the
> preyList via a ForEach command when one of the prey
> attempts to add a new member to the preyList. This
> could cause problems as the preyList is changing 
> under its iterator. I'll defer to Roger as to whether
> this is "safe" or not at the moment.

[...]

> it may be safe to add the
> new prey to the preyList directly, if you always add
> them to the beginning of the list, which presumably
> the iterator has already passed over - again I
> defer to Roger Burkhart who wrote the collections 
> package on what the proper thing to do is, and
> on the safety of modifying the preyList directly
> underneath an active iterator.

*Adding* to a simple list never causes any problem to any active index,
regardless of where that index is positioned.  It's only removing from a
list while an index is at that position that causes any problem.  You
should be able to add before or after an active index position (e.g., the
one held by ForEach) or anywhere else in the list without causing a
problem.

An upgrade of collections that provides safe removal as well as other
operations is currently in progress.

Roger


reply via email to

[Prev in Thread] Current Thread [Next in Thread]