Oh, I see what you mean.  You're right.  I don't know what I was thinking
(not enough coffee yet or something).  The BoundedBuffer wrapper would
actually enforce a maximum size and wait until something was removed from it
(there you'd have to also override the remove and clear methods and the
iterator implementation I believe).  So, the BoundedBuffer class would need
a few settings:

boolean waitWhenFull;
long maximumWait;
int maximumSize;

If waitWhenFull is false, then it just throws a BufferOverflowException
(sounds so villainous).  The maximumWait would default to -1 (wait forever).

The TimoutBuffer wouldn't need to have a "waitOnEmpty" setting, since you'd
just use the default implementation which would throw a
BufferUnderflowException.  We would need a maximumWait property on
TimeoutBuffer, though (defaulting to -1 also).  Does this sound right?



-----Original Message-----
From: Stephen Colebourne [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 10, 2005 7:40 AM
To: Jakarta Commons Developers List
Subject: Re: [collections] New Buffer Wrapper Classes...

These sound like good ideas.

Not sure why you need two TimeoutWrappers though, as
you are only trapping the remove() aren't you?

Stephen

--- James Carman <[EMAIL PROTECTED]> wrote:
> Based on my response to Sandy McArthur about using
> Buffers to implements
> Commons Pool, I started digging around the API.  I
> came up with a couple of
> ideas:
> 
> 1.  A BoundedBuffer wrapper/decorator class, which
> basically enforces a
> maximum size of the enclosed buffer.
> 
> 2.  A TimeoutBuffer wrapper/decorator class which
> waits until a specified
> timeout value expires when asking to remove()
> objects from an empty Buffer. 
> 
> With these two classes, we can make any underlying
> implementation (stack,
> queue, priority queue, etc.) bounded or cause them
> to wait rather than throw
> a BufferUnderflowException immediately when removing
> objects from them.  We
> may have to come up with two timeout wrappers, one
> for read and one for
> write (optionally they could be in the same class
> with potentially different
> values for each).  What do you guys think?


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to