Package org.apache.mina.util

Examples of org.apache.mina.util.Stack


    /**
     * Allocate or get the buffer which is capable of the specified size.
     */
    private static ByteBuffer allocate(int idx) {
        Stack stack = bufferStacks[idx];

        ByteBuffer buf;
        synchronized (stack) {
            buf = (ByteBuffer) stack.pop();
            if (buf == null) {
                buf = createBuffer(bufferStackSizes[idx]);
            }
        }

View Full Code Here


        // Sweep buffer for security.
        org.apache.mina.common.ByteBuffer.wrap(buf).sweep().release();

        int stackIndex = getBufferStackIndex(buf.capacity());
        if (stackIndex >= PACKET_BUFFER_INDEX) {
            Stack stack = bufferStacks[getBufferStackIndex(buf.capacity())];
            synchronized (stack) {
                stack.push(buf);
            }
        }
    }
View Full Code Here

   
    private static java.nio.ByteBuffer allocate0( int capacity, boolean direct )
    {
        Stack[] bufferStacks = direct? directBufferStacks : heapBufferStacks;
        int idx = getBufferStackIndex( bufferStacks, capacity );
        Stack stack = bufferStacks[ idx ];

        java.nio.ByteBuffer buf;
        synchronized( stack )
        {
            buf = ( java.nio.ByteBuffer ) stack.pop();
        }

        if( buf == null )
        {
            buf = direct ? java.nio.ByteBuffer.allocateDirect( MINIMUM_CAPACITY << idx ) :
View Full Code Here

    }
   
    private static void release0( java.nio.ByteBuffer buf )
    {
        Stack[] bufferStacks = buf.isDirect()? directBufferStacks : heapBufferStacks;
        Stack stack = bufferStacks[ getBufferStackIndex( bufferStacks, buf.capacity() ) ];
        synchronized( stack )
        {
            // push back
            stack.push( buf );
        }
    }
View Full Code Here

    /**
     * Allocate or get the buffer which is capable of the specified size.
     */
    private static ByteBuffer allocate( int idx )
    {
        Stack stack = bufferStacks[ idx ];

        ByteBuffer buf;
        synchronized( stack )
        {
            buf = ( ByteBuffer ) stack.pop();
            if( buf == null )
            {
                buf = createBuffer( bufferStackSizes[ idx ] );
            }
        }
View Full Code Here

     */
    public static void release( ByteBuffer buf )
    {
        int stackIndex =getBufferStackIndex( buf.capacity() );
        if ( stackIndex >= PACKET_BUFFER_INDEX ) {
            Stack stack = bufferStacks[getBufferStackIndex( buf.capacity() )];
            synchronized ( stack ) {
                stack.push( buf );
            }
        }
    }
View Full Code Here

    /**
     * Allocate or get the buffer which is capable of the specified size.
     */
    private static ByteBuffer allocate( int idx )
    {
        Stack stack = bufferStacks[ idx ];

        ByteBuffer buf;
        synchronized( stack )
        {
            buf = ( ByteBuffer ) stack.pop();
            if( buf == null )
            {
                buf = createBuffer( bufferStackSizes[ idx ] );
            }
        }
View Full Code Here

        // Sweep buffer for security.
        org.apache.mina.common.ByteBuffer.wrap( buf ).sweep().release();

        int stackIndex =getBufferStackIndex( buf.capacity() );
        if ( stackIndex >= PACKET_BUFFER_INDEX ) {
            Stack stack = bufferStacks[getBufferStackIndex( buf.capacity() )];
            synchronized ( stack ) {
                stack.push( buf );
            }
        }
    }
View Full Code Here

    /**
     * Allocate or get the buffer which is capable of the specified size.
     */
    private static ByteBuffer allocate( int idx )
    {
        Stack stack = bufferStacks[ idx ];

        ByteBuffer buf;
        synchronized( stack )
        {
            buf = ( ByteBuffer ) stack.pop();
            if( buf == null )
            {
                buf = createBuffer( bufferStackSizes[ idx ] );
            }
        }
View Full Code Here

     */
    public static void release( ByteBuffer buf )
    {
        int stackIndex =getBufferStackIndex( buf.capacity() );
        if ( stackIndex >= PACKET_BUFFER_INDEX ) {
            Stack stack = bufferStacks[getBufferStackIndex( buf.capacity() )];
            synchronized ( stack ) {
                stack.push( buf );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.mina.util.Stack

Copyright © 2018 www.massapicom. 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.