Table of Contents

Class BufferPool

Namespace
easyar

BufferPool implements a memory pool. It can be used for features that repeatedly allocate memory of the same size, such as custom camera access, reducing time spent on memory allocation.

BufferPool

Constructors

BufferPool

block_size is the byte size of each Buffer. capacity is the maximum number of Buffer objects.

void easyar_BufferPool__ctor(int block_size, int capacity, easyar_BufferPool * * Return)
BufferPool(int block_size, int capacity)
public BufferPool(int block_size, int capacity)
constructor(block_size: Int, capacity: Int)
+ (easyar_BufferPool *) create:(int)block_size capacity:(int)capacity
public convenience init(_ block_size: Int32, _ capacity: Int32)
public BufferPool(int block_size, int capacity)

Parameters

Name Type Description
block_size Int32
capacity Int32

Methods

block_size

Byte size of each Buffer.

int easyar_BufferPool_block_size(const easyar_BufferPool * This)
int block_size()
public int block_size()
fun block_size(): Int
- (int)block_size
public func block_size() -> Int32
public virtual int block_size()

Returns

Type Description
Int32

capacity

Maximum number of Buffer objects.

int easyar_BufferPool_capacity(const easyar_BufferPool * This)
int capacity()
public int capacity()
fun capacity(): Int
- (int)capacity
public func capacity() -> Int32
public virtual int capacity()

Returns

Type Description
Int32

size

Current number of Buffer objects obtained externally.

int easyar_BufferPool_size(const easyar_BufferPool * This)
int size()
public int size()
fun size(): Int
- (int)size
public func size() -> Int32
public virtual int size()

Returns

Type Description
Int32

tryAcquire

Tries to obtain a memory block. If the current number of externally obtained Buffer objects has not reached the maximum number of Buffer objects, it retrieves or allocates a new Buffer; otherwise, it returns empty.

void easyar_BufferPool_tryAcquire(easyar_BufferPool * This, easyar_OptionalOfBuffer * Return)
std::optional<std::shared_ptr<Buffer>> tryAcquire()
public @Nullable Buffer tryAcquire()
fun tryAcquire(): Buffer?
- (easyar_Buffer *)tryAcquire
public func tryAcquire() -> Buffer?
public virtual Optional<Buffer> tryAcquire()

Returns

Type Description
Optional<Buffer>