gnash-commit
[Top][All Lists]
Advanced

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

Re: [Gnash-commit] gnash/server dlist.cpp


From: strk
Subject: Re: [Gnash-commit] gnash/server dlist.cpp
Date: Thu, 24 Aug 2006 01:44:21 +0200

Guys, I just realized that we might be talking about nothing here.
The DisplayList is a std::list, so as any insertion or deletion
would still keep the same end() value, and would never invalidate
an iterator, right ?
I'd ask Vitaly to provide a testcase justifying his change.
Also, the previous code was checking for size() change, and
warning user if it happened.

--strk;

On Thu, Aug 24, 2006 at 01:34:23AM +0200, Bastiaan Jacques wrote:
> On Wednesday 23 August 2006 23:44, strk wrote:
> > On Wed, Aug 23, 2006 at 05:03:11PM +0200, Bastiaan Jacques wrote:
> > > What about:
> > >
> > > for (iterator it = _characters.begin(); it != _characters.end();
> > > ++it) { // ..
> > > }
> > >
> > > ?
> > >
> > > This would save you a copy and (I believe) would be safer than the
> > > original.
> >
> > If the container can change (as the comments suggest)
> > we need more info about "how" could it change, as I don't think
> > that testing for .end() would be enough to be "safe".
> 
> Right, so, the question is: can the container change size in between the 
> _characters.end() call and when we use it?
> 
> The answer is probably yes. It's significantly less likely if you check 
> in each iteration, but it can still happen.
> 
> One solution is to have a copy of the container. This, of course, has 
> its downsides: if we advance a character that has been deleted in the 
> original character list, it may be there for too long (and we may 
> render something that should already be gone). And of course we copy 
> the character list itself, which uses memory and processor time.
> 
> Another solution would be to make this function a 'critical section' in 
> a threading context: this will ensure that nobody can delete anything 
> until we've finished advancing our whole character list.
> 
> The best solution would be, I think, is to maintain an owning reference 
> to the character we are attempting to use. So, if someone is trying to 
> delete the character we are using, we make them wait until we've 
> released our hold on the character.
> 
> I'm not sure how much work would be involved in doing that, though.
> 
> > BTW, I've verified in the past that testing for .end() or .size() and
> > friends in a for condition is actually slower then caching it in
> > the initializer.
> 
> Yes, that makes sense.
> 
> Bastiaan
> 
> 
> _______________________________________________
> Gnash-commit mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gnash-commit

-- 

 /"\    ASCII Ribbon Campaign
 \ /    Respect for low technology.
  X     Keep e-mail messages readable by any computer system.
 / \    Keep it ASCII. 





reply via email to

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