Package org.apache.cassandra.net
Class ShareableBytes
- java.lang.Object
-
- org.apache.cassandra.net.ShareableBytes
-
public class ShareableBytes extends java.lang.ObjectA wrapper for possibly sharing portions of a single,BufferPools.forNetworking()managed,ByteBuffer; optimised for the case where no sharing is necessary. When sharing is necessary,share()method must be invoked by the owning thread before aShareableBytesinstance can be shared with another thread.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBufferget()booleanhasRemaining()voidrelease()intremaining()ShareableBytesshare()Ensure this ShareableBytes will use atomic operations for updating its count from now on.ShareableBytessliceAndConsume(int length)Create a slice over the nextlengthbytes, consuming them from our buffer, and incrementing the owner countstatic ShareableByteswrap(java.nio.ByteBuffer buffer)
-
-
-
Method Detail
-
get
public java.nio.ByteBuffer get()
-
hasRemaining
public boolean hasRemaining()
-
remaining
public int remaining()
-
share
public ShareableBytes share()
Ensure this ShareableBytes will use atomic operations for updating its count from now on. The first invocation must occur while the calling thread has exclusive access (though there may be more than one 'owner', these must all either be owned by the calling thread or otherwise not being used)
-
release
public void release()
-
sliceAndConsume
public ShareableBytes sliceAndConsume(int length)
Create a slice over the nextlengthbytes, consuming them from our buffer, and incrementing the owner count
-
wrap
public static ShareableBytes wrap(java.nio.ByteBuffer buffer)
-
-