Package etch.util.core.nio

Examples of etch.util.core.nio.ByteBufferPool.release()


    ByteBufferPool p = new ByteBufferPool( 4096, 0, 10, 0, 0 );
    ByteBuffer b = p.alloc( null );
    assertNotNull( b );
    assertEquals( 4096, b.limit() );
    assertEquals( 1, p.used() );
    p.release( b );
    assertEquals( 0, p.used() );
  }
 
  /** @throws Exception */
  @Test
 
View Full Code Here


    ByteBufferPool p = new ByteBufferPool( 1024, 0, 10, 0, 0 );
    ByteBuffer b = p.alloc( null );
    assertNotNull( b );
    assertEquals( 1024, b.limit() );
    assertEquals( 1, p.used() );
    p.release( b );
    assertEquals( 0, p.used() );
  }
 
  /** @throws Exception */
  @Test
 
View Full Code Here

    assertNotNull( b[0] );
    assertEquals( 4096, b[0].limit() );
    assertNotNull( b[1] );
    assertEquals( 4096, b[1].limit() );
    assertEquals( 2, p.used() );
    p.release( b );
    assertEquals( 0, p.used() );
  }
 
  /** @throws Exception */
  @Test( expected = IOException.class )
View Full Code Here

  public void alloc5() throws Exception
  {
    // slower because of no pooling.
    ByteBufferPool p = new ByteBufferPool( 1024, 0, 1, 0, 0 );
    for (int i = 0; i < 100000; i++)
      p.release( p.alloc( null ) );
    assertEquals( 0, p.used() );
  }
 
  /** @throws Exception */
  @Test
 
View Full Code Here

  public void alloc6() throws Exception
  {
    // faster because of pooling.
    ByteBufferPool p = new ByteBufferPool( 1024, 1, 1, 0, 0 );
    for (int i = 0; i < 100000; i++)
      p.release( p.alloc( null ) );
    assertEquals( 0, p.used() );
  }
 
  /** @throws Exception */
  @Test
 
View Full Code Here

    assertFalse( n2.available );
   
    // the alloc of b2 failed, but n2 should be registered to be notified
    // when a block is freed. release of b1 should notify n2 of availability
   
    p.release( b1 );
    b1 = null;
    assertEquals( 0, p.used() );
    Thread.sleep( 15 );
    assertFalse( n1.available );
    assertTrue( n2.available );
View Full Code Here

    assertEquals( 1, p.used() );
    Thread.sleep( 15 );
    assertFalse( n1.available );
    assertFalse( n2.available );
   
    p.release( b2 );
    b2 = null;
    assertEquals( 0, p.used() );
    Thread.sleep( 15 );
    assertFalse( n1.available );
    assertFalse( n2.available );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.