模块 wjybxx.base

类 SimpleByteArrayPool

java.lang.Object
cn.wjybxx.base.io.SimpleByteArrayPool
所有已实现的接口:
ObjectPool<byte[]>, Supplier<byte[]>

@NotThreadSafe public class SimpleByteArrayPool extends Object implements ObjectPool<byte[]>
作者:
wjybxx date 2023/3/31
  • 构造器详细资料

    • SimpleByteArrayPool

      public SimpleByteArrayPool(int poolSize, int bufferSize)
    • SimpleByteArrayPool

      public SimpleByteArrayPool(int poolSize, int bufferSize, boolean clear)
      参数:
      poolSize - 池大小
      bufferSize - 数组大小
      clear - 字节素组归入池中时是否clear
  • 方法详细资料

    • rent

      @Nonnull public byte[] rent()
      从接口复制的说明: ObjectPool
      从池中租借一个对象
      指定者:
      rent 在接口中 ObjectPool<byte[]>
      返回:
      如果池中有可用的对象,则返回缓存的对象,否则返回一个新的对象
    • returnOne

      public void returnOne(byte[] buffer)
      从接口复制的说明: ObjectPool
      将指定的对象放入池中 - 重置策略却决于ResetPolicy
      指定者:
      returnOne 在接口中 ObjectPool<byte[]>
      参数:
      buffer - 要回收的对象
    • clear

      public void clear()
      从接口复制的说明: ObjectPool
      删除此池中的所有对象 (可空实现)
      指定者:
      clear 在接口中 ObjectPool<byte[]>