Due to the existing structure of code, which looks like this:
// Read buffer (using ByteBuffer)
// Pass buffer to a remote method, which MIGHT write to it
// Write buffer back if dirty
I want that my buffer should be able to identify if it is written to (if it's dirty). I didn't find any buffer implementation in java with a dirty flag.
In all these cases my code is already passing around ByteBuffers
, in order to add this dirty flag should I:
- simply wrap the
ByteBuffer
implementation with dirty flag - Write a class with underlying
byte
array, add dirty big and other operations (get/put int or long) and re-create theByteBuffer
by wrapping around thebyte
array - Extend the
ByteBuffer
class? (I'd be happy to implement the get/put but there are WAY TOO many methods to be implemented)
Also, what are the overheads of wrapping the ByteBuffer
implementation?