BufferPool Class

Description

BufferPool 实现了一个内存池,可用于自定义摄像头接入等需要反复分配相同大小内存的功能,降低内存分配耗时。

Constructor

block_size为每个 Buffer 的字节大小。

capacity为最大 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

每个 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

最大 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

当前外部获得的 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

尝试获得内存块。如果当前外部获得的 Buffer 数量没有达到最大 Buffer 数量,则取出或分配一个新的 Buffer ,否则返回空。

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()