com.sun.corba.se.pept.transport.ByteBufferPool Java Examples

The following examples show how to use com.sun.corba.se.pept.transport.ByteBufferPool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: ByteBufferWithInfo.java    License: Apache License 2.0 5 votes vote down vote up
public ByteBufferWithInfo(org.omg.CORBA.ORB orb,
                          BufferManagerWrite bufferManager,
                          boolean usePooledByteBuffers)
{
    this.orb = (com.sun.corba.se.spi.orb.ORB)orb;
    debug = this.orb.transportDebugFlag;

    int bufferSize = bufferManager.getBufferSize();

    if (usePooledByteBuffers)
    {
        ByteBufferPool byteBufferPool = this.orb.getByteBufferPool();
        this.byteBuffer = byteBufferPool.getByteBuffer(bufferSize);

        if (debug)
        {
            // print address of ByteBuffer gotten from pool
            int bbAddress = System.identityHashCode(byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append("constructor (ORB, BufferManagerWrite) - got ")
              .append("ByteBuffer id (").append(bbAddress)
              .append(") from ByteBufferPool.");
            String msgStr = sb.toString();
            dprint(msgStr);
        }
    }
    else
    {
         // don't allocate from pool, allocate non-direct ByteBuffer
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
    }

    position(0);
    this.buflen = bufferSize;
    this.byteBuffer.limit(this.buflen);
    this.needed = 0;
    this.fragmented = false;
}
 
Example #2
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BufferManagerWriteCollect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #3
Source Project: openjdk-8   Author: bpupadhyaya   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #4
Source Project: TencentKona-8   Author: Tencent   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #5
Source Project: jdk8u60   Author: chenghanpeng   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #6
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: ByteBufferWithInfo.java    License: MIT License 5 votes vote down vote up
public ByteBufferWithInfo(org.omg.CORBA.ORB orb,
                          BufferManagerWrite bufferManager,
                          boolean usePooledByteBuffers)
{
    this.orb = (com.sun.corba.se.spi.orb.ORB)orb;
    debug = this.orb.transportDebugFlag;

    int bufferSize = bufferManager.getBufferSize();

    if (usePooledByteBuffers)
    {
        ByteBufferPool byteBufferPool = this.orb.getByteBufferPool();
        this.byteBuffer = byteBufferPool.getByteBuffer(bufferSize);

        if (debug)
        {
            // print address of ByteBuffer gotten from pool
            int bbAddress = System.identityHashCode(byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append("constructor (ORB, BufferManagerWrite) - got ")
              .append("ByteBuffer id (").append(bbAddress)
              .append(") from ByteBufferPool.");
            String msgStr = sb.toString();
            dprint(msgStr);
        }
    }
    else
    {
         // don't allocate from pool, allocate non-direct ByteBuffer
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
    }

    position(0);
    this.buflen = bufferSize;
    this.byteBuffer.limit(this.buflen);
    this.needed = 0;
    this.fragmented = false;
}
 
Example #7
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: BufferManagerWriteCollect.java    License: MIT License 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #8
Source Project: openjdk-8   Author: bpupadhyaya   File: ByteBufferWithInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ByteBufferWithInfo(org.omg.CORBA.ORB orb,
                          BufferManagerWrite bufferManager,
                          boolean usePooledByteBuffers)
{
    this.orb = (com.sun.corba.se.spi.orb.ORB)orb;
    debug = this.orb.transportDebugFlag;

    int bufferSize = bufferManager.getBufferSize();

    if (usePooledByteBuffers)
    {
        ByteBufferPool byteBufferPool = this.orb.getByteBufferPool();
        this.byteBuffer = byteBufferPool.getByteBuffer(bufferSize);

        if (debug)
        {
            // print address of ByteBuffer gotten from pool
            int bbAddress = System.identityHashCode(byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append("constructor (ORB, BufferManagerWrite) - got ")
              .append("ByteBuffer id (").append(bbAddress)
              .append(") from ByteBufferPool.");
            String msgStr = sb.toString();
            dprint(msgStr);
        }
    }
    else
    {
         // don't allocate from pool, allocate non-direct ByteBuffer
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
    }

    position(0);
    this.buflen = bufferSize;
    this.byteBuffer.limit(this.buflen);
    this.needed = 0;
    this.fragmented = false;
}
 
Example #9
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #10
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ByteBufferWithInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ByteBufferWithInfo(org.omg.CORBA.ORB orb,
                          BufferManagerWrite bufferManager,
                          boolean usePooledByteBuffers)
{
    this.orb = (com.sun.corba.se.spi.orb.ORB)orb;
    debug = this.orb.transportDebugFlag;

    int bufferSize = bufferManager.getBufferSize();

    if (usePooledByteBuffers)
    {
        ByteBufferPool byteBufferPool = this.orb.getByteBufferPool();
        this.byteBuffer = byteBufferPool.getByteBuffer(bufferSize);

        if (debug)
        {
            // print address of ByteBuffer gotten from pool
            int bbAddress = System.identityHashCode(byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append("constructor (ORB, BufferManagerWrite) - got ")
              .append("ByteBuffer id (").append(bbAddress)
              .append(") from ByteBufferPool.");
            String msgStr = sb.toString();
            dprint(msgStr);
        }
    }
    else
    {
         // don't allocate from pool, allocate non-direct ByteBuffer
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
    }

    position(0);
    this.buflen = bufferSize;
    this.byteBuffer.limit(this.buflen);
    this.needed = 0;
    this.fragmented = false;
}
 
Example #11
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #12
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ByteBufferWithInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ByteBufferWithInfo(org.omg.CORBA.ORB orb,
                          BufferManagerWrite bufferManager,
                          boolean usePooledByteBuffers)
{
    this.orb = (com.sun.corba.se.spi.orb.ORB)orb;
    debug = this.orb.transportDebugFlag;

    int bufferSize = bufferManager.getBufferSize();

    if (usePooledByteBuffers)
    {
        ByteBufferPool byteBufferPool = this.orb.getByteBufferPool();
        this.byteBuffer = byteBufferPool.getByteBuffer(bufferSize);

        if (debug)
        {
            // print address of ByteBuffer gotten from pool
            int bbAddress = System.identityHashCode(byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append("constructor (ORB, BufferManagerWrite) - got ")
              .append("ByteBuffer id (").append(bbAddress)
              .append(") from ByteBufferPool.");
            String msgStr = sb.toString();
            dprint(msgStr);
        }
    }
    else
    {
         // don't allocate from pool, allocate non-direct ByteBuffer
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
    }

    position(0);
    this.buflen = bufferSize;
    this.byteBuffer.limit(this.buflen);
    this.needed = 0;
    this.fragmented = false;
}
 
Example #13
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #14
Source Project: hottub   Author: dsrg-uoft   File: ByteBufferWithInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ByteBufferWithInfo(org.omg.CORBA.ORB orb,
                          BufferManagerWrite bufferManager,
                          boolean usePooledByteBuffers)
{
    this.orb = (com.sun.corba.se.spi.orb.ORB)orb;
    debug = this.orb.transportDebugFlag;

    int bufferSize = bufferManager.getBufferSize();

    if (usePooledByteBuffers)
    {
        ByteBufferPool byteBufferPool = this.orb.getByteBufferPool();
        this.byteBuffer = byteBufferPool.getByteBuffer(bufferSize);

        if (debug)
        {
            // print address of ByteBuffer gotten from pool
            int bbAddress = System.identityHashCode(byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append("constructor (ORB, BufferManagerWrite) - got ")
              .append("ByteBuffer id (").append(bbAddress)
              .append(") from ByteBufferPool.");
            String msgStr = sb.toString();
            dprint(msgStr);
        }
    }
    else
    {
         // don't allocate from pool, allocate non-direct ByteBuffer
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
    }

    position(0);
    this.buflen = bufferSize;
    this.byteBuffer.limit(this.buflen);
    this.needed = 0;
    this.fragmented = false;
}
 
Example #15
Source Project: hottub   Author: dsrg-uoft   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #16
Source Project: openjdk-8-source   Author: keerath   File: ByteBufferWithInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ByteBufferWithInfo(org.omg.CORBA.ORB orb,
                          BufferManagerWrite bufferManager,
                          boolean usePooledByteBuffers)
{
    this.orb = (com.sun.corba.se.spi.orb.ORB)orb;
    debug = this.orb.transportDebugFlag;

    int bufferSize = bufferManager.getBufferSize();

    if (usePooledByteBuffers)
    {
        ByteBufferPool byteBufferPool = this.orb.getByteBufferPool();
        this.byteBuffer = byteBufferPool.getByteBuffer(bufferSize);

        if (debug)
        {
            // print address of ByteBuffer gotten from pool
            int bbAddress = System.identityHashCode(byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append("constructor (ORB, BufferManagerWrite) - got ")
              .append("ByteBuffer id (").append(bbAddress)
              .append(") from ByteBufferPool.");
            String msgStr = sb.toString();
            dprint(msgStr);
        }
    }
    else
    {
         // don't allocate from pool, allocate non-direct ByteBuffer
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
    }

    position(0);
    this.buflen = bufferSize;
    this.byteBuffer.limit(this.buflen);
    this.needed = 0;
    this.fragmented = false;
}
 
Example #17
Source Project: openjdk-8-source   Author: keerath   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close the BufferManagerWrite - do any outstanding cleanup.
 *
 * For a BufferManagerWriteGrow any queued ByteBufferWithInfo must
 * have its ByteBuffer released to the ByteBufferPool.
 */
public void close()
{
    // iterate thru queue and release any ByteBufferWithInfo's
    // ByteBuffer that may be remaining on the queue to the
    // ByteBufferPool.

    Iterator bufs = iterator();

    ByteBufferPool byteBufferPool = orb.getByteBufferPool();

    while (bufs.hasNext())
    {
        ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
        if (bbwi != null && bbwi.byteBuffer != null)
        {
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("close() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
             byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
             bbwi.byteBuffer = null;
             bbwi = null;
        }
    }
}
 
Example #18
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: CorbaTransportManagerImpl.java    License: Apache License 2.0 4 votes vote down vote up
public ByteBufferPool getByteBufferPool(int id)
{
    throw new RuntimeException();
}
 
Example #19
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BufferManagerWriteCollect.java    License: Apache License 2.0 4 votes vote down vote up
public void sendMessage ()
{
    // Enqueue the last fragment
    queue.enqueue(((CDROutputObject)outputObject).getByteBufferWithInfo());

    Iterator bufs = iterator();

    Connection conn =
                      ((OutputObject)outputObject).getMessageMediator().
                                                   getConnection();

    // With the collect strategy, we must lock the connection
    // while fragments are being sent.  This is so that there are
    // no interleved fragments in GIOP 1.1.
    //
    // Note that this thread must not call writeLock again in any
    // of its send methods!
    conn.writeLock();

    try {

        // Get a reference to ByteBufferPool so that the ByteBufferWithInfo
        // ByteBuffer can be released to the ByteBufferPool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();

        while (bufs.hasNext()) {

            ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
            ((CDROutputObject)outputObject).setByteBufferWithInfo(bbwi);

            conn.sendWithoutLock(((CDROutputObject)outputObject));

            sentFragment = true;

            // Release ByteBufferWithInfo's ByteBuffer back to the pool
            // of ByteBuffers.
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("sendMessage() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
            byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
            bbwi.byteBuffer = null;
            bbwi = null;
        }

        sentFullMessage = true;

    } finally {

        conn.writeUnlock();
    }
}
 
Example #20
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BufferManagerReadStream.java    License: Apache License 2.0 4 votes vote down vote up
public ByteBufferWithInfo underflow (ByteBufferWithInfo bbwi)
{

  ByteBufferWithInfo result = null;

  try {
      //System.out.println("ENTER underflow");

    synchronized (fragmentQueue) {

        if (receivedCancel) {
            throw new RequestCanceledException(cancelReqId);
        }

        while (fragmentQueue.size() == 0) {

            if (endOfStream) {
                throw wrapper.endOfStream() ;
            }

            boolean interrupted = false;
            try {
                fragmentQueue.wait(FRAGMENT_TIMEOUT);
            } catch (InterruptedException e) {
                interrupted = true;
            }

            if (!interrupted && fragmentQueue.size() == 0) {
                throw wrapper.bufferReadManagerTimeout();
            }

            if (receivedCancel) {
                throw new RequestCanceledException(cancelReqId);
            }
        }

        result = fragmentQueue.dequeue();
        result.fragmented = true;

        if (debug)
        {
            // print address of ByteBuffer being dequeued
            int bbAddr = System.identityHashCode(result.byteBuffer);
            StringBuffer sb1 = new StringBuffer(80);
            sb1.append("underflow() - dequeued ByteBuffer id (");
            sb1.append(bbAddr).append(") from fragment queue.");
            String msg1 = sb1.toString();
            dprint(msg1);
        }

        // VERY IMPORTANT
        // Release bbwi.byteBuffer to the ByteBufferPool only if
        // this BufferManagerStream is not marked for potential restore.
        if (markEngaged == false && bbwi != null && bbwi.byteBuffer != null)
        {
            ByteBufferPool byteBufferPool = getByteBufferPool();

            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("underflow() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }

            byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
            bbwi.byteBuffer = null;
            bbwi = null;
        }
    }
    return result;
  } finally {
      //System.out.println("EXIT underflow");
  }
}
 
Example #21
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BufferManagerReadStream.java    License: Apache License 2.0 4 votes vote down vote up
protected ByteBufferPool getByteBufferPool()
{
    return orb.getByteBufferPool();
}
 
Example #22
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: CDRInputStream_1_0.java    License: Apache License 2.0 4 votes vote down vote up
public void close() throws IOException
{

    // tell BufferManagerRead to release any ByteBuffers
    getBufferManager().close(bbwi);

    // It's possible bbwi.byteBuffer is shared between
    // this InputStream and an OutputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (bbwi != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDROutputObject outputObj =
                         (CDROutputObject)messageMediator.getOutputObject();
            if (outputObj != null)
            {
                if (outputObj.isSharing(getByteBuffer()))
                {
                    // Set OutputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    outputObj.setByteBuffer(null);
                    outputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
        }
        byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
        bbwi.byteBuffer = null;
        bbwi = null;
    }
}
 
Example #23
Source Project: openjdk-8   Author: bpupadhyaya   File: CDROutputStream_1_0.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void close() throws IOException
{
    // tell BufferManagerWrite to release any ByteBuffers
    getBufferManager().close();

    // It's possible bbwi.byteBuffer is shared between
    // this OutputStream and an InputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (getByteBufferWithInfo() != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDRInputObject inputObj =
                           (CDRInputObject)messageMediator.getInputObject();
            if (inputObj != null)
            {
                if (inputObj.isSharing(getByteBuffer()))
                {
                    // Set InputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    inputObj.setByteBuffer(null);
                    inputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
         }
         byteBufferPool.releaseByteBuffer(getByteBuffer());
         bbwi.byteBuffer = null;
         bbwi = null;
    }
}
 
Example #24
Source Project: TencentKona-8   Author: Tencent   File: CDROutputStream_1_0.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void close() throws IOException
{
    // tell BufferManagerWrite to release any ByteBuffers
    getBufferManager().close();

    // It's possible bbwi.byteBuffer is shared between
    // this OutputStream and an InputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (getByteBufferWithInfo() != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDRInputObject inputObj =
                           (CDRInputObject)messageMediator.getInputObject();
            if (inputObj != null)
            {
                if (inputObj.isSharing(getByteBuffer()))
                {
                    // Set InputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    inputObj.setByteBuffer(null);
                    inputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
         }
         byteBufferPool.releaseByteBuffer(getByteBuffer());
         bbwi.byteBuffer = null;
         bbwi = null;
    }
}
 
Example #25
Source Project: TencentKona-8   Author: Tencent   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void sendMessage ()
{
    // Enqueue the last fragment
    queue.enqueue(((CDROutputObject)outputObject).getByteBufferWithInfo());

    Iterator bufs = iterator();

    Connection conn =
                      ((OutputObject)outputObject).getMessageMediator().
                                                   getConnection();

    // With the collect strategy, we must lock the connection
    // while fragments are being sent.  This is so that there are
    // no interleved fragments in GIOP 1.1.
    //
    // Note that this thread must not call writeLock again in any
    // of its send methods!
    conn.writeLock();

    try {

        // Get a reference to ByteBufferPool so that the ByteBufferWithInfo
        // ByteBuffer can be released to the ByteBufferPool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();

        while (bufs.hasNext()) {

            ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
            ((CDROutputObject)outputObject).setByteBufferWithInfo(bbwi);

            conn.sendWithoutLock(((CDROutputObject)outputObject));

            sentFragment = true;

            // Release ByteBufferWithInfo's ByteBuffer back to the pool
            // of ByteBuffers.
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("sendMessage() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
            byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
            bbwi.byteBuffer = null;
            bbwi = null;
        }

        sentFullMessage = true;

    } finally {

        conn.writeUnlock();
    }
}
 
Example #26
Source Project: TencentKona-8   Author: Tencent   File: BufferManagerReadStream.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ByteBufferWithInfo underflow (ByteBufferWithInfo bbwi)
{

  ByteBufferWithInfo result = null;

  try {
      //System.out.println("ENTER underflow");

    synchronized (fragmentQueue) {

        if (receivedCancel) {
            throw new RequestCanceledException(cancelReqId);
        }

        while (fragmentQueue.size() == 0) {

            if (endOfStream) {
                throw wrapper.endOfStream() ;
            }

            boolean interrupted = false;
            try {
                fragmentQueue.wait(FRAGMENT_TIMEOUT);
            } catch (InterruptedException e) {
                interrupted = true;
            }

            if (!interrupted && fragmentQueue.size() == 0) {
                throw wrapper.bufferReadManagerTimeout();
            }

            if (receivedCancel) {
                throw new RequestCanceledException(cancelReqId);
            }
        }

        result = fragmentQueue.dequeue();
        result.fragmented = true;

        if (debug)
        {
            // print address of ByteBuffer being dequeued
            int bbAddr = System.identityHashCode(result.byteBuffer);
            StringBuffer sb1 = new StringBuffer(80);
            sb1.append("underflow() - dequeued ByteBuffer id (");
            sb1.append(bbAddr).append(") from fragment queue.");
            String msg1 = sb1.toString();
            dprint(msg1);
        }

        // VERY IMPORTANT
        // Release bbwi.byteBuffer to the ByteBufferPool only if
        // this BufferManagerStream is not marked for potential restore.
        if (markEngaged == false && bbwi != null && bbwi.byteBuffer != null)
        {
            ByteBufferPool byteBufferPool = getByteBufferPool();

            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("underflow() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }

            byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
            bbwi.byteBuffer = null;
            bbwi = null;
        }
    }
    return result;
  } finally {
      //System.out.println("EXIT underflow");
  }
}
 
Example #27
Source Project: TencentKona-8   Author: Tencent   File: BufferManagerReadStream.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected ByteBufferPool getByteBufferPool()
{
    return orb.getByteBufferPool();
}
 
Example #28
Source Project: TencentKona-8   Author: Tencent   File: CDRInputStream_1_0.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void close() throws IOException
{

    // tell BufferManagerRead to release any ByteBuffers
    getBufferManager().close(bbwi);

    // It's possible bbwi.byteBuffer is shared between
    // this InputStream and an OutputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (bbwi != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDROutputObject outputObj =
                         (CDROutputObject)messageMediator.getOutputObject();
            if (outputObj != null)
            {
                if (outputObj.isSharing(getByteBuffer()))
                {
                    // Set OutputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    outputObj.setByteBuffer(null);
                    outputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
        }
        byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
        bbwi.byteBuffer = null;
        bbwi = null;
    }
}
 
Example #29
Source Project: jdk8u60   Author: chenghanpeng   File: CorbaTransportManagerImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ByteBufferPool getByteBufferPool(int id)
{
    throw new RuntimeException();
}
 
Example #30
Source Project: openjdk-8   Author: bpupadhyaya   File: BufferManagerReadStream.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ByteBufferWithInfo underflow (ByteBufferWithInfo bbwi)
{

  ByteBufferWithInfo result = null;

  try {
      //System.out.println("ENTER underflow");

    synchronized (fragmentQueue) {

        if (receivedCancel) {
            throw new RequestCanceledException(cancelReqId);
        }

        while (fragmentQueue.size() == 0) {

            if (endOfStream) {
                throw wrapper.endOfStream() ;
            }

            boolean interrupted = false;
            try {
                fragmentQueue.wait(FRAGMENT_TIMEOUT);
            } catch (InterruptedException e) {
                interrupted = true;
            }

            if (!interrupted && fragmentQueue.size() == 0) {
                throw wrapper.bufferReadManagerTimeout();
            }

            if (receivedCancel) {
                throw new RequestCanceledException(cancelReqId);
            }
        }

        result = fragmentQueue.dequeue();
        result.fragmented = true;

        if (debug)
        {
            // print address of ByteBuffer being dequeued
            int bbAddr = System.identityHashCode(result.byteBuffer);
            StringBuffer sb1 = new StringBuffer(80);
            sb1.append("underflow() - dequeued ByteBuffer id (");
            sb1.append(bbAddr).append(") from fragment queue.");
            String msg1 = sb1.toString();
            dprint(msg1);
        }

        // VERY IMPORTANT
        // Release bbwi.byteBuffer to the ByteBufferPool only if
        // this BufferManagerStream is not marked for potential restore.
        if (markEngaged == false && bbwi != null && bbwi.byteBuffer != null)
        {
            ByteBufferPool byteBufferPool = getByteBufferPool();

            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("underflow() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }

            byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
            bbwi.byteBuffer = null;
            bbwi = null;
        }
    }
    return result;
  } finally {
      //System.out.println("EXIT underflow");
  }
}