Hi,
I have some questions regarding the correct use of ByteBuffers. It would
be fine, if someone could explain in some short words, how it works.
1) In a decoder method I want to do a pattern search. Can I assume, that
in the meantime (imagine the search takes longer) the incoming
ByteBuffer doesn't increase? Or with other words: I want store the
in.remaining() in a local variable tLen ... must I do an aquire()
before, that the local variable and the remaining() value are the same
until the method ends?
2) Imagine I use instead of the SimpleByteBufferAllocator the default
one. Now it can happen, that while long lasting decoding additional
worker threads will be opened. When I'm right and I've added my Decoder
to the Acceptor chain (not to each session), now exists for each worker
thread one decoder. Right? Can I assume, that for a defined session XYZ
all incoming data chunks flows through the same decoder or can it
happen, that in the worst case one data snippet for the session XYZ
flows through decoder A and the second through decoder B and that in the
worsest case parallel?
3) When I do in my decoder some pattern search and don't restore the
position in the ByteBuffer to the initial one, can I assume, that the
data are consumed and will be dropped / overwritten or simple cleared
through the system in the next time? Or must I modify the incoming
ByteBuffer for such things in that way, that I create a new ByteBuffer,
where I copy only a part from the incoming buffer and forward it?
4) For a pattern search in the ByteBuffer I want to use a modified Boyer
Moore algorithm. That means, that I have to skip chunks of bytes in the
ByteBuffer and must use instead of simple get() the get(index) method.
Two questions: Will the get(index) method change the position() of the
ByteBuffer too? And ... seems the idea to be good or do you think, that
the use of simple get() method works faster?
Hope, somebody can help :)
Best Regards
Michael