>>>>> "Berin" == Berin Loritsch <[EMAIL PROTECTED]> writes: Berin> Question: Do you have actual multiprocessor systems to test Berin> on? This is one of my main limitations.
Nope, just plain single CPU Linux 2.4 box with jdk 1.4. Attached is the promissed test case and a patch for VariableSizeBuffer. With the new code QueueTest works fine. But I share Leo's concern about DefaultQueue implementation. I will send a separate email about it.
Index: src/java/org/apache/avalon/excalibur/collections/VariableSizeBuffer.java =================================================================== RCS file: /home/cvspublic/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/collections/VariableSizeBuffer.java,v retrieving revision 1.4 diff -u -r1.4 VariableSizeBuffer.java --- src/java/org/apache/avalon/excalibur/collections/VariableSizeBuffer.java 26 Feb 2002 02:07:50 -0000 1.4 +++ src/java/org/apache/avalon/excalibur/collections/VariableSizeBuffer.java 5 Mar +2002 19:40:12 -0000 @@ -88,13 +88,22 @@ { Object[] tmp = new Object[ ( (m_buffer.length - 1) * 2) + 1 ]; - for ( int i = 0; i < m_buffer.length; i++ ) + int j = 0; + for ( int i = m_head; i != m_tail; ) { - tmp[i] = m_buffer[i]; + tmp[j] = m_buffer[i]; m_buffer[i] = null; + + j++; + i++; + if (i == m_buffer.length) { + i = 0; + } } m_buffer = tmp; + m_head = 0; + m_tail = j; } m_buffer[ m_tail ] = o;
package org.apache.avalon.excalibur.collections.test; import junit.framework.TestCase; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.avalon.excalibur.collections.VariableSizeBuffer; public class VariableSizeBufferTestCase extends TestCase { public VariableSizeBufferTestCase( final String name ) { super( name ); } /** * Triggers a situation when m_tail < m_head during buffer * extension, so copying will be wrapping around the end of * the buffer. */ public void testGrowthWrapAround () throws Exception { VariableSizeBuffer buf = new VariableSizeBuffer(1); buf.add("1"); assertEquals("Got 1 that just added", "1", buf.remove()); buf.add("2"); buf.add("3"); assertEquals("After 3 puts and 1 remove buffer size must be 2", 2, buf.size()); assertEquals("Got 2", "2", buf.remove()); assertEquals("Got 3", "3", buf.remove()); assertTrue("Buffer is empty", buf.isEmpty()); } /** * Extension is done when m_head = 0 and m_tail = m_buffer.length - 1. */ public void testGrowthCopyStartToEnd() { VariableSizeBuffer buf = new VariableSizeBuffer(1); buf.add("1"); buf.add("2"); assertEquals("After 2 puts buffer size must be 2", 2, buf.size()); assertEquals("Got 1", "1", buf.remove()); assertEquals("Got 2", "2", buf.remove()); assertTrue("Buffer is empty", buf.isEmpty()); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>