Package io.undertow.util
Class ReferenceCountedPooled
java.lang.Object
io.undertow.util.ReferenceCountedPooled
- All Implemented Interfaces:
PooledByteBuffer
,Closeable
,AutoCloseable
A reference counted pooled implementation, that basically consists of a main buffer, that can be sliced off into smaller buffers,
and the underlying buffer will not be freed until all the slices and the main buffer itself have also been freed.
This also supports the notion of un-freeing the main buffer. Basically this allows the buffer be re-used, so if only a small slice of the
buffer was used for read operations the main buffer can potentially be re-used. This prevents buffer exhaustion attacks where content
is sent in many small packets, and you end up allocating a large number of buffers to hold a small amount of data.
- Author:
- Stuart Douglas
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionReferenceCountedPooled
(PooledByteBuffer underlying, int referenceCount) ReferenceCountedPooled
(PooledByteBuffer underlying, int referenceCount, ReferenceCountedPooled.FreeNotifier freeNotifier) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
createView
(int viewSize) void
boolean
isFreed()
boolean
isOpen()
toString()
boolean
-
Constructor Details
-
ReferenceCountedPooled
-
ReferenceCountedPooled
public ReferenceCountedPooled(PooledByteBuffer underlying, int referenceCount, ReferenceCountedPooled.FreeNotifier freeNotifier)
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacePooledByteBuffer
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfacePooledByteBuffer
-
isFreed
public boolean isFreed() -
tryUnfree
public boolean tryUnfree() -
getBuffer
- Specified by:
getBuffer
in interfacePooledByteBuffer
- Throws:
IllegalStateException
-
createView
-
createView
-
increaseReferenceCount
public void increaseReferenceCount() -
toString
-