BufferPool Class

Description

BufferPool is a memory pool to reduce memory allocation time consumption for functionality like custom camera interoperability, which needs to allocate memory buffers of a fixed size repeatedly.

Constructor

block_size is the byte size of each Buffer .

capacity is the maximum count of Buffer .

C: void easyar_BufferPool__ctor(int block_size, int capacity, easyar_BufferPool * * Return)
C++17: BufferPool(int block_size, int capacity)
Traditional C++: BufferPool(int block_size, int capacity)
Java: public BufferPool(int block_size, int capacity)
Kotlin: constructor(block_size: Int, capacity: Int)
Objective-C: + (easyar_BufferPool *) create:(int)block_size capacity:(int)capacity
Swift: public convenience init(_ block_size: Int32, _ capacity: Int32)
C#: public BufferPool(int block_size, int capacity)

block_size

The byte size of each Buffer .

C: int easyar_BufferPool_block_size(const easyar_BufferPool * This)
C++17: int block_size()
Traditional C++: int block_size()
Java: public int block_size()
Kotlin: fun block_size(): Int
Objective-C: - (int)block_size
Swift: public func block_size() -> Int32
C#: public virtual int block_size()

capacity

The maximum count of Buffer .

C: int easyar_BufferPool_capacity(const easyar_BufferPool * This)
C++17: int capacity()
Traditional C++: int capacity()
Java: public int capacity()
Kotlin: fun capacity(): Int
Objective-C: - (int)capacity
Swift: public func capacity() -> Int32
C#: public virtual int capacity()

size

Current acquired count of Buffer .

C: int easyar_BufferPool_size(const easyar_BufferPool * This)
C++17: int size()
Traditional C++: int size()
Java: public int size()
Kotlin: fun size(): Int
Objective-C: - (int)size
Swift: public func size() -> Int32
C#: public virtual int size()

tryAcquire

Tries to acquire a memory block. If current acquired count of Buffer does not reach maximum, a new Buffer is fetched or allocated, or else null is returned.

C: void easyar_BufferPool_tryAcquire(easyar_BufferPool * This, easyar_OptionalOfBuffer * Return)
C++17: std::optional<std::shared_ptr<Buffer>> tryAcquire()
Traditional C++: void tryAcquire(Buffer * * Return)
Java: public @Nullable Buffer tryAcquire()
Kotlin: fun tryAcquire(): Buffer?
Objective-C: - (easyar_Buffer *)tryAcquire
Swift: public func tryAcquire() -> Buffer?
C#: public virtual Optional<Buffer> tryAcquire()