org.gudy.azureus2.core3.util
Class DirectByteBuffer
java.lang.Object
org.gudy.azureus2.core3.util.DirectByteBuffer
- Direct Known Subclasses:
- ReferenceCountedDirectByteBuffer
public class DirectByteBuffer
- extends java.lang.Object
Virtual direct byte buffer given out and tracker
by the buffer pool.
Method Summary |
int |
capacity(byte subsystem)
|
void |
clear(byte subsystem)
|
protected void |
dumpTrace(java.lang.Throwable e)
|
void |
flip(byte subsystem)
|
byte |
get(byte subsystem)
|
void |
get(byte subsystem,
byte[] data)
|
byte |
get(byte subsystem,
int x)
|
protected byte |
getAllocator()
|
java.nio.ByteBuffer |
getBuffer(byte subsystem)
|
protected java.nio.ByteBuffer |
getBufferInternal()
|
boolean |
getFlag(byte flag)
|
int |
getInt(byte subsystem)
|
int |
getInt(byte subsystem,
int x)
|
ReferenceCountedDirectByteBuffer |
getReferenceCountedBuffer()
|
short |
getShort(byte subsystem)
|
protected java.lang.String |
getTraceString()
|
boolean |
hasRemaining(byte subsystem)
|
int |
limit(byte subsystem)
|
void |
limit(byte subsystem,
int l)
|
int |
position(byte subsystem)
|
void |
position(byte subsystem,
int l)
|
void |
put(byte subsystem,
byte data)
|
void |
put(byte subsystem,
byte[] data)
|
void |
put(byte subsystem,
byte[] data,
int offset,
int length)
|
void |
put(byte subsystem,
java.nio.ByteBuffer data)
|
void |
put(byte subsystem,
DirectByteBuffer data)
|
void |
putInt(byte subsystem,
int data)
|
void |
putShort(byte subsystem,
short x)
|
int |
read(byte subsystem,
java.nio.channels.FileChannel chan)
|
int |
read(byte subsystem,
java.nio.channels.SocketChannel chan)
|
int |
remaining(byte subsystem)
|
void |
returnToPool()
|
void |
returnToPoolIfNotFree()
Normally you should know when a buffer is/isn't free and NOT CALL THIS METHOD
However, there are some error situations where the existing code doesn't correctly
manage things - we know this and don't want spurious logs occuring as per the above
normal method |
void |
setFlag(byte flag)
|
protected void |
traceUsage(byte subsystem,
byte operation)
|
int |
write(byte subsystem,
java.nio.channels.FileChannel chan)
|
int |
write(byte subsystem,
java.nio.channels.SocketChannel chan)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AL_NONE
public static final byte AL_NONE
- See Also:
- Constant Field Values
AL_EXTERNAL
public static final byte AL_EXTERNAL
- See Also:
- Constant Field Values
AL_OTHER
public static final byte AL_OTHER
- See Also:
- Constant Field Values
AL_PT_READ
public static final byte AL_PT_READ
- See Also:
- Constant Field Values
AL_PT_LENGTH
public static final byte AL_PT_LENGTH
- See Also:
- Constant Field Values
AL_CACHE_READ
public static final byte AL_CACHE_READ
- See Also:
- Constant Field Values
AL_DM_READ
public static final byte AL_DM_READ
- See Also:
- Constant Field Values
AL_DM_ZERO
public static final byte AL_DM_ZERO
- See Also:
- Constant Field Values
AL_DM_CHECK
public static final byte AL_DM_CHECK
- See Also:
- Constant Field Values
AL_BT_PIECE
public static final byte AL_BT_PIECE
- See Also:
- Constant Field Values
AL_CACHE_WRITE
public static final byte AL_CACHE_WRITE
- See Also:
- Constant Field Values
AL_PROXY_RELAY
public static final byte AL_PROXY_RELAY
- See Also:
- Constant Field Values
AL_MSG
public static final byte AL_MSG
- See Also:
- Constant Field Values
AL_MSG_AZ_HAND
public static final byte AL_MSG_AZ_HAND
- See Also:
- Constant Field Values
AL_MSG_AZ_PEX
public static final byte AL_MSG_AZ_PEX
- See Also:
- Constant Field Values
AL_MSG_BT_CANCEL
public static final byte AL_MSG_BT_CANCEL
- See Also:
- Constant Field Values
AL_MSG_BT_HAND
public static final byte AL_MSG_BT_HAND
- See Also:
- Constant Field Values
AL_MSG_BT_HAVE
public static final byte AL_MSG_BT_HAVE
- See Also:
- Constant Field Values
AL_MSG_BT_PIECE
public static final byte AL_MSG_BT_PIECE
- See Also:
- Constant Field Values
AL_MSG_BT_REQUEST
public static final byte AL_MSG_BT_REQUEST
- See Also:
- Constant Field Values
AL_MSG_BT_KEEPALIVE
public static final byte AL_MSG_BT_KEEPALIVE
- See Also:
- Constant Field Values
AL_MSG_BT_HEADER
public static final byte AL_MSG_BT_HEADER
- See Also:
- Constant Field Values
AL_MSG_AZ_HEADER
public static final byte AL_MSG_AZ_HEADER
- See Also:
- Constant Field Values
AL_MSG_BT_PAYLOAD
public static final byte AL_MSG_BT_PAYLOAD
- See Also:
- Constant Field Values
AL_MSG_AZ_PAYLOAD
public static final byte AL_MSG_AZ_PAYLOAD
- See Also:
- Constant Field Values
AL_FILE
public static final byte AL_FILE
- See Also:
- Constant Field Values
AL_NET_CRYPT
public static final byte AL_NET_CRYPT
- See Also:
- Constant Field Values
AL_MSG_LT_EXT_MESSAGE
public static final byte AL_MSG_LT_EXT_MESSAGE
- See Also:
- Constant Field Values
AL_MSG_LT_HANDSHAKE
public static final byte AL_MSG_LT_HANDSHAKE
- See Also:
- Constant Field Values
AL_MSG_UT_PEX
public static final byte AL_MSG_UT_PEX
- See Also:
- Constant Field Values
AL_MSG_BT_DHT_PORT
public static final byte AL_MSG_BT_DHT_PORT
- See Also:
- Constant Field Values
AL_MSG_BT_REJECT_REQUEST
public static final byte AL_MSG_BT_REJECT_REQUEST
- See Also:
- Constant Field Values
AL_MSG_BT_SUGGEST_PIECE
public static final byte AL_MSG_BT_SUGGEST_PIECE
- See Also:
- Constant Field Values
AL_MSG_BT_ALLOWED_FAST
public static final byte AL_MSG_BT_ALLOWED_FAST
- See Also:
- Constant Field Values
AL_MSG_UT_METADATA
public static final byte AL_MSG_UT_METADATA
- See Also:
- Constant Field Values
AL_MSG_AZ_METADATA
public static final byte AL_MSG_AZ_METADATA
- See Also:
- Constant Field Values
AL_MSG_UT_UPLOAD_ONLY
public static final byte AL_MSG_UT_UPLOAD_ONLY
- See Also:
- Constant Field Values
AL_DESCS
public static final java.lang.String[] AL_DESCS
SS_NONE
public static final byte SS_NONE
- See Also:
- Constant Field Values
SS_EXTERNAL
public static final byte SS_EXTERNAL
- See Also:
- Constant Field Values
SS_OTHER
public static final byte SS_OTHER
- See Also:
- Constant Field Values
SS_CACHE
public static final byte SS_CACHE
- See Also:
- Constant Field Values
SS_FILE
public static final byte SS_FILE
- See Also:
- Constant Field Values
SS_NET
public static final byte SS_NET
- See Also:
- Constant Field Values
SS_BT
public static final byte SS_BT
- See Also:
- Constant Field Values
SS_DR
public static final byte SS_DR
- See Also:
- Constant Field Values
SS_DW
public static final byte SS_DW
- See Also:
- Constant Field Values
SS_PEER
public static final byte SS_PEER
- See Also:
- Constant Field Values
SS_PROXY
public static final byte SS_PROXY
- See Also:
- Constant Field Values
SS_MSG
public static final byte SS_MSG
- See Also:
- Constant Field Values
SS_DESCS
public static final java.lang.String[] SS_DESCS
OP_LIMIT
public static final byte OP_LIMIT
- See Also:
- Constant Field Values
OP_LIMIT_INT
public static final byte OP_LIMIT_INT
- See Also:
- Constant Field Values
OP_POSITION
public static final byte OP_POSITION
- See Also:
- Constant Field Values
OP_POSITION_INT
public static final byte OP_POSITION_INT
- See Also:
- Constant Field Values
OP_CLEAR
public static final byte OP_CLEAR
- See Also:
- Constant Field Values
OP_FLIP
public static final byte OP_FLIP
- See Also:
- Constant Field Values
OP_REMANING
public static final byte OP_REMANING
- See Also:
- Constant Field Values
OP_CAPACITY
public static final byte OP_CAPACITY
- See Also:
- Constant Field Values
OP_PUT_BYTEARRAY
public static final byte OP_PUT_BYTEARRAY
- See Also:
- Constant Field Values
OP_PUT_DBB
public static final byte OP_PUT_DBB
- See Also:
- Constant Field Values
OP_PUT_BB
public static final byte OP_PUT_BB
- See Also:
- Constant Field Values
OP_PUTINT
public static final byte OP_PUTINT
- See Also:
- Constant Field Values
OP_PUT_BYTE
public static final byte OP_PUT_BYTE
- See Also:
- Constant Field Values
OP_GET
public static final byte OP_GET
- See Also:
- Constant Field Values
OP_GET_INT
public static final byte OP_GET_INT
- See Also:
- Constant Field Values
OP_GET_BYTEARRAY
public static final byte OP_GET_BYTEARRAY
- See Also:
- Constant Field Values
OP_GETINT
public static final byte OP_GETINT
- See Also:
- Constant Field Values
OP_GETINT_INT
public static final byte OP_GETINT_INT
- See Also:
- Constant Field Values
OP_HASREMAINING
public static final byte OP_HASREMAINING
- See Also:
- Constant Field Values
OP_READ_FC
public static final byte OP_READ_FC
- See Also:
- Constant Field Values
OP_WRITE_FC
public static final byte OP_WRITE_FC
- See Also:
- Constant Field Values
OP_READ_SC
public static final byte OP_READ_SC
- See Also:
- Constant Field Values
OP_WRITE_SC
public static final byte OP_WRITE_SC
- See Also:
- Constant Field Values
OP_GETBUFFER
public static final byte OP_GETBUFFER
- See Also:
- Constant Field Values
OP_GETSHORT
public static final byte OP_GETSHORT
- See Also:
- Constant Field Values
OP_PUTSHORT
public static final byte OP_PUTSHORT
- See Also:
- Constant Field Values
OP_DESCS
public static final java.lang.String[] OP_DESCS
FL_NONE
public static final byte FL_NONE
- See Also:
- Constant Field Values
FL_CONTAINS_TRANSIENT_DATA
public static final byte FL_CONTAINS_TRANSIENT_DATA
- See Also:
- Constant Field Values
TRACE
protected static final boolean TRACE
- See Also:
- Constant Field Values
TRACE_BUFFER_SIZE
protected static final int TRACE_BUFFER_SIZE
- See Also:
- Constant Field Values
DirectByteBuffer
public DirectByteBuffer(java.nio.ByteBuffer _buffer)
DirectByteBuffer
public DirectByteBuffer(byte _allocator,
java.nio.ByteBuffer _buffer,
DirectByteBufferPool _pool)
DirectByteBuffer
protected DirectByteBuffer(DirectByteBuffer basis)
- constructor for reference counted version
- Parameters:
basis
-
getReferenceCountedBuffer
public ReferenceCountedDirectByteBuffer getReferenceCountedBuffer()
setFlag
public void setFlag(byte flag)
getFlag
public boolean getFlag(byte flag)
traceUsage
protected void traceUsage(byte subsystem,
byte operation)
getTraceString
protected java.lang.String getTraceString()
dumpTrace
protected void dumpTrace(java.lang.Throwable e)
getBufferInternal
protected java.nio.ByteBuffer getBufferInternal()
getAllocator
protected byte getAllocator()
limit
public int limit(byte subsystem)
limit
public void limit(byte subsystem,
int l)
position
public int position(byte subsystem)
position
public void position(byte subsystem,
int l)
clear
public void clear(byte subsystem)
flip
public void flip(byte subsystem)
remaining
public int remaining(byte subsystem)
capacity
public int capacity(byte subsystem)
put
public void put(byte subsystem,
byte[] data)
put
public void put(byte subsystem,
byte[] data,
int offset,
int length)
put
public void put(byte subsystem,
DirectByteBuffer data)
put
public void put(byte subsystem,
java.nio.ByteBuffer data)
put
public void put(byte subsystem,
byte data)
putShort
public void putShort(byte subsystem,
short x)
putInt
public void putInt(byte subsystem,
int data)
get
public byte get(byte subsystem)
get
public byte get(byte subsystem,
int x)
get
public void get(byte subsystem,
byte[] data)
getShort
public short getShort(byte subsystem)
getInt
public int getInt(byte subsystem)
getInt
public int getInt(byte subsystem,
int x)
hasRemaining
public boolean hasRemaining(byte subsystem)
read
public int read(byte subsystem,
java.nio.channels.FileChannel chan)
throws java.io.IOException
- Throws:
java.io.IOException
write
public int write(byte subsystem,
java.nio.channels.FileChannel chan)
throws java.io.IOException
- Throws:
java.io.IOException
read
public int read(byte subsystem,
java.nio.channels.SocketChannel chan)
throws java.io.IOException
- Throws:
java.io.IOException
write
public int write(byte subsystem,
java.nio.channels.SocketChannel chan)
throws java.io.IOException
- Throws:
java.io.IOException
getBuffer
public java.nio.ByteBuffer getBuffer(byte subsystem)
returnToPool
public void returnToPool()
returnToPoolIfNotFree
public void returnToPoolIfNotFree()
- Normally you should know when a buffer is/isn't free and NOT CALL THIS METHOD
However, there are some error situations where the existing code doesn't correctly
manage things - we know this and don't want spurious logs occuring as per the above
normal method