Package org.apache.cassandra.net
Class ShareableBytes
- java.lang.Object
-
- org.apache.cassandra.net.ShareableBytes
-
public class ShareableBytes extends java.lang.Object
A 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 aShareableBytes
instance can be shared with another thread.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
get()
boolean
hasRemaining()
void
release()
int
remaining()
ShareableBytes
share()
Ensure this ShareableBytes will use atomic operations for updating its count from now on.ShareableBytes
sliceAndConsume(int length)
Create a slice over the nextlength
bytes, consuming them from our buffer, and incrementing the owner countstatic ShareableBytes
wrap(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 nextlength
bytes, consuming them from our buffer, and incrementing the owner count
-
wrap
public static ShareableBytes wrap(java.nio.ByteBuffer buffer)
-
-