All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----edu.utah.janos.nodeos.pj_BufferHandle
Summary |
class pj_BufferHandle extends java.lang.Object { // Fields 8 private static final int MAX_PACKET_LEN; private byte[] data; private DeliverFunc deliverFunc; private int length; private pj_BufferHandle next; private int offset; private int payloadStart; private pj_BufferHandle prev; // Constructors 1 protected pj_BufferHandle(pj_BufferHandle, int, int); // Methods 28 static int getMaxPacketLen(); pj_BufferHandle addToQueueHead(pj_BufferHandle); pj_BufferHandle addToQueueTail(pj_BufferHandle); void clearIncomingState(); void cloneHandle(pj_BufferHandle, int, int); void dbgPacketSummary(StringBuffer, int, int); byte getByte(int); byte[] getByteArray(); void getBytes(int, byte[], int, int); DeliverFunc getDeliverFunc(); int getInt(int); int getLength(); int getOffset(); int getPayloadStart(); boolean isSingletonQueue(); void newBuffer(int, int); boolean notOnAQueue(); boolean onAQueue(); pj_BufferHandle prev(); pj_BufferHandle removeFromQueue(); void reset(); void setByte(int, byte); void setBytes(int, byte[], int, int); void setIncomingState(DeliverFunc, int); void setInt(int, int); void setLength(int); void swapWith(pj_BufferHandle, int, int); public String toString(); }
pj_BufferHandle does not need to do array bounds checks or to synchronize access. (Done by the wrapper layer.)
A pj_BufferHandle can be on one of three queues: a pj_InChannel's free buffer queue, a pj_OutChannel's outgoing queue, or a pj_ThreadPool's dispatched BufferQ (waiting to be handled).
XXX I belive all of the synchronized statements in here are redundant with protections necessairly provided by the caller. I think.
XXX cannot synchronize on the pj_BufferHandle object, as it is externally visible and is shared with the dispatcher.
See Also: BufferHandle, pj_InChannel, pj_OutChannel, pj_ThreadPool
Cross Reference |
Fields |
· MAX_PACKET_LEN | Summary | Top |
private static final int MAX_PACKET_LEN
· data | Summary | Top |
private byte[] data
The actual data buffer. Should be allocated in fixed size chunks.
· length | Summary | Top |
private int length
Length of the valid region of the data.
· offset | Summary | Top |
private int offset
Current offset into the buffer
· next | Summary | Top |
private pj_BufferHandle next
For the free buffer queue on InChannels and OutChannels.
See Also: InChannel, OutChannel
· prev | Summary | Top |
private pj_BufferHandle prev
For the free buffer queue on InChannels and OutChannels.
See Also: InChannel, OutChannel
· deliverFunc | Summary | Top |
private DeliverFunc deliverFunc
The deliver func associated with incoming packets that are queued up in a ThreadPool.
· payloadStart | Summary | Top |
private int payloadStart
The payload start associated with incoming packets that are queud up in a ThreadPool.
See Also: handle
Constructors |
· pj_BufferHandle | Summary | Top |
protected pj_BufferHandle(pj_BufferHandle other, int offset, int length)
Methods |
· getMaxPacketLen | Summary | Top |
static int getMaxPacketLen()
· getLength | Summary | Top |
int getLength()
· getOffset | Summary | Top |
int getOffset()
· setIncomingState | Summary | Top |
void setIncomingState(DeliverFunc f, int payloadStart)
Set the state associated with incoming buffers.
Parameter Description f the deliver func associated with the InChannel this BufferHandle was dispatched out of payloadStart an integer associated with the buffer. internally used to mark the first byte after the filter in this buffer, but may be anything (from InChannelHandle.push()).
· clearIncomingState | Summary | Top |
void clearIncomingState()
· getDeliverFunc | Summary | Top |
DeliverFunc getDeliverFunc()
· getPayloadStart | Summary | Top |
int getPayloadStart()
· setLength | Summary | Top |
void setLength(int len)
For pj_* layer internal use only.
· getByteArray | Summary | Top |
byte[] getByteArray()
· reset | Summary | Top |
void reset()
Reset this BufferHandle, dropping the buffer it points to and setting offset and length to zero.
· newBuffer | Summary | Top |
void newBuffer(int offset, int length)
· cloneHandle | Summary | Top |
void cloneHandle(pj_BufferHandle src, int fromOffset, int fromLength)
· swapWith | Summary | Top |
void swapWith(pj_BufferHandle src, int fromOffset, int fromLength)
Swap the contents of this pj_BufferHandle with the given src pj_BufferHandle. Only the data, offset and length fields are copied (the other must be irrelevant). Only the specified sub-sequence of the src buffer is "copied" into this buffer handle.
Parameter Description src the buffer to swap with this fromOffset the offset (in addition to src.offset) to set in this fromLength the new length of this buffer
· getByte | Summary | Top |
byte getByte(int index)
· setByte | Summary | Top |
void setByte(int index, byte val)
· getInt | Summary | Top |
int getInt(int index)
· setInt | Summary | Top |
void setInt(int index, int val)
· getBytes | Summary | Top |
void getBytes(int srcPosition, byte[] dest, int destPosition, int destLength)
· setBytes | Summary | Top |
void setBytes(int destPosition, byte[] src, int srcPosition, int srcLength)
· notOnAQueue | Summary | Top |
boolean notOnAQueue()
Debugging only. Returns true if this buffer is not on a queue (i.e, next == prev == null).
· onAQueue | Summary | Top |
boolean onAQueue()
Debugging only. Returns true if this buffer is on a queue.
· isSingletonQueue | Summary | Top |
boolean isSingletonQueue()
· addToQueueHead | Summary | Top |
pj_BufferHandle addToQueueHead(pj_BufferHandle q)
Add this packet buffer to the "head" of given queue q. Q is doubly linked, the new head (this) is returned.
If queue is: A <> B <> C <> A, and this is X. New queue will be X <> A <> B <> C <> X.
Parameter Description q pointer to the first element of the list (or null).
- Returns:
- the new head of the list (always this).
· addToQueueTail | Summary | Top |
pj_BufferHandle addToQueueTail(pj_BufferHandle q)
Add this pj_BufferHandle to tail of the given queue. Returns the new queue *head* (if it changes).
XXX Note that this is identical to addToQueueHead() except for the final return statement.
· prev | Summary | Top |
pj_BufferHandle prev()
· removeFromQueue | Summary | Top |
pj_BufferHandle removeFromQueue()
Remove this pb from the queue it is on. It must be on a queue. Return the following item on the list (thus if this is head of list, then it returns a new head).
- Returns:
- the new
head of the queue.
· dbgPacketSummary | Summary | Top |
void dbgPacketSummary(StringBuffer sbuf, int offset, int len)
· toString | Summary | Top |
public String toString()
- Overrides:
- toString in class Object
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7