当前位置: 首页>>代码示例>>Java>>正文


Java ByteBufferPool类代码示例

本文整理汇总了Java中com.sun.corba.se.pept.transport.ByteBufferPool的典型用法代码示例。如果您正苦于以下问题:Java ByteBufferPool类的具体用法?Java ByteBufferPool怎么用?Java ByteBufferPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ByteBufferPool类属于com.sun.corba.se.pept.transport包,在下文中一共展示了ByteBufferPool类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ByteBufferWithInfo

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:ByteBufferWithInfo.java

示例2: close

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
/**
 * 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;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:BufferManagerWriteCollect.java

示例3: getByteBufferPool

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
public ByteBufferPool getByteBufferPool(int id)
{
    throw new RuntimeException();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:CorbaTransportManagerImpl.java

示例4: close

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:CDROutputStream_1_0.java

示例5: sendMessage

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:BufferManagerWriteCollect.java

示例6: underflow

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
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");
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:79,代码来源:BufferManagerReadStream.java

示例7: getByteBufferPool

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
protected ByteBufferPool getByteBufferPool()
{
    return orb.getByteBufferPool();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:BufferManagerReadStream.java

示例8: close

import com.sun.corba.se.pept.transport.ByteBufferPool; //导入依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:CDRInputStream_1_0.java


注:本文中的com.sun.corba.se.pept.transport.ByteBufferPool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。