public class

NativePooledByteBuffer

extends Object
implements PooledByteBuffer
java.lang.Object
   ↳ com.facebook.imagepipeline.memory.NativePooledByteBuffer

Class Overview

An implementation of PooledByteBuffer that uses native memory (NativeMemoryChunk) to store data

Summary

Public Constructors
NativePooledByteBuffer(CloseableReference<NativeMemoryChunk> bufRef, int size)
Public Methods
synchronized void close()
Closes this instance, and releases the underlying buffer to the pool.
synchronized long getNativePtr()
synchronized boolean isClosed()
Check if this bytebuffer is already closed
synchronized void read(int offset, byte[] buffer, int bufferOffset, int length)
Read consecutive bytes.
synchronized byte read(int offset)
Read byte at given offset
synchronized int size()
Gets the size of the bytebuffer if it is valid.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.facebook.common.memory.PooledByteBuffer
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public Constructors

public NativePooledByteBuffer (CloseableReference<NativeMemoryChunk> bufRef, int size)

Public Methods

public synchronized void close ()

Closes this instance, and releases the underlying buffer to the pool. Once the bytebuffer has been closed, subsequent operations (especially getStream() will fail. Note: It is not an error to close an already closed bytebuffer

public synchronized long getNativePtr ()

public synchronized boolean isClosed ()

Check if this bytebuffer is already closed

Returns
  • true if this bytebuffer is closed.

public synchronized void read (int offset, byte[] buffer, int bufferOffset, int length)

Read consecutive bytes.

Parameters
offset the position in the PooledByteBuffer of the first byte to read
buffer the byte array where read bytes will be copied to
bufferOffset the position within the buffer of the first copied byte
length number of bytes to copy
Returns
  • number of bytes copied

public synchronized byte read (int offset)

Read byte at given offset

Returns
  • byte at given offset

public synchronized int size ()

Gets the size of the bytebuffer if it is valid. Otherwise, an exception is raised

Returns
  • the size of the bytebuffer if it is not closed.
Throws
ClosedException}