You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Jack, Paul" <pj...@sfaf.org> on 2002/06/27 20:22:01 UTC

[SUBMIT][Collections] Buffer stuff from Avalon

http://www.geocities.com/apachecollections/buffers

-Paul


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SUBMIT][Collections] Buffer stuff from Avalon

Posted by "Michael A. Smith" <ma...@apache.org>.
On Thu, 27 Jun 2002, Stephen Colebourne wrote:
> I understood that the correct way to syncgronize was
> synchronize (list) {
>   for (Iterator it = list.iterator(); it.hasNext();) {
>   ...
>   }
> }
> Maybe I'm wrong...

no, that's the way that Sun decided to implement 
Collections.synchronizedFoo, so you're right.  I was just saying that I 
thought Sun could have implemented the iterator so that wasn't required 
for a multi-thread safe iterator.

> > Speaking of the naming proposal, have you had a chance to write
> > something up?  I'm fairly certain I will have time this weekend, but
> > don't want to duplicate effort if you've already gotten something put
> > together that you just haven't finished/submitted yet.
> 
> Submitted a few days ago
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=commons-dev@jakarta.apac
> he.org&msgId=377897

doh.  I even saved it for review.

sorry 'bout that...

michael


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SUBMIT][Collections] Buffer stuff from Avalon

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Michael A. Smith" <ma...@apache.org>
> On Thu, 27 Jun 2002, Stephen Colebourne wrote:
> > In the synchronizedBuffer implementation, the iterator() method should
> > probably NOT be synchronized. The equivalent in java.util.Collections
isn't
> > and has a suitable comment instead.
>
> I've always thought it was weird that the interator was unsynchronized.
> There's no reason each method on the iterator can't synchronize on the
> appropriate object to ensure consistency in a multi-threaded
> environment.  But, alas, Sun decided against it and just added a
> comment.  I haven't had a chance to look at what Paul put together, but
> I'm inclined to agree with Stephen here that we should behave similarly
> to java.util.Collections.synchronizedFoo().

I understood that the correct way to syncgronize was
synchronize (list) {
  for (Iterator it = list.iterator(); it.hasNext();) {
  ...
  }
}
Maybe I'm wrong...

> > Also, should BoundedFifo be named BoundedFifoBuffer? and the same with
> > Unbounded? If not, then the naming proposal needs a minor alteration.
(and
> > it should probably be voted on again)
>
> Speaking of the naming proposal, have you had a chance to write
> something up?  I'm fairly certain I will have time this weekend, but
> don't want to duplicate effort if you've already gotten something put
> together that you just haven't finished/submitted yet.

Submitted a few days ago
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=commons-dev@jakarta.apac
he.org&msgId=377897

Stephen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [SUBMIT][Collections] Buffer stuff from Avalon

Posted by Berin Loritsch <bl...@apache.org>.
> From: Michael A. Smith [mailto:mas@apache.org] 
> 
> On Thu, 27 Jun 2002, Stephen Colebourne wrote:
> > In the synchronizedBuffer implementation, the iterator() 
> method should 
> > probably NOT be synchronized. The equivalent in 
> java.util.Collections 
> > isn't and has a suitable comment instead.
> 
> I've always thought it was weird that the interator was 
> unsynchronized.  
> There's no reason each method on the iterator can't 
> synchronize on the 
> appropriate object to ensure consistency in a multi-threaded 
> environment.  But, alas, Sun decided against it and just added a 
> comment.  I haven't had a chance to look at what Paul put 
> together, but 
> I'm inclined to agree with Stephen here that we should behave 
> similarly 
> to java.util.Collections.synchronizedFoo(). 


Consider how the iterator is used.  It is _supposed_ to be
a short lived object that is used within one thread.  It is
typically used for the quick loop like this:

Iterator it = l_buffer.iterator();

while( it.hasNext() )
{
    Object o = it.next();
    // do stuff
}


If separate threads are using the same buffer/list, they
usually have their own iterators.  Kind of like the JDK 1.4
NIO stuff.  Each listening thread has its own selector,
and operates on it.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SUBMIT][Collections] Buffer stuff from Avalon

Posted by "Michael A. Smith" <ma...@apache.org>.
On Thu, 27 Jun 2002, Stephen Colebourne wrote:
> In the synchronizedBuffer implementation, the iterator() method should
> probably NOT be synchronized. The equivalent in java.util.Collections isn't
> and has a suitable comment instead.

I've always thought it was weird that the interator was unsynchronized.  
There's no reason each method on the iterator can't synchronize on the 
appropriate object to ensure consistency in a multi-threaded 
environment.  But, alas, Sun decided against it and just added a 
comment.  I haven't had a chance to look at what Paul put together, but 
I'm inclined to agree with Stephen here that we should behave similarly 
to java.util.Collections.synchronizedFoo(). 

> Also, should BoundedFifo be named BoundedFifoBuffer? and the same with
> Unbounded? If not, then the naming proposal needs a minor alteration. (and
> it should probably be voted on again)

Speaking of the naming proposal, have you had a chance to write 
something up?  I'm fairly certain I will have time this weekend, but 
don't want to duplicate effort if you've already gotten something put 
together that you just haven't finished/submitted yet.

regards,
michael


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SUBMIT][Collections] Buffer stuff from Avalon

Posted by Stephen Colebourne <sc...@btopenworld.com>.
In the synchronizedBuffer implementation, the iterator() method should
probably NOT be synchronized. The equivalent in java.util.Collections isn't
and has a suitable comment instead.

Also, should BoundedFifo be named BoundedFifoBuffer? and the same with
Unbounded? If not, then the naming proposal needs a minor alteration. (and
it should probably be voted on again)

Stephen

----- Original Message -----
From: "Jack, Paul" <pj...@sfaf.org>
To: <co...@jakarta.apache.org>
Sent: Thursday, June 27, 2002 7:22 PM
Subject: [SUBMIT][Collections] Buffer stuff from Avalon


> http://www.geocities.com/apachecollections/buffers
>
> -Paul
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>