Skip to content

Commit 2a323dd

Browse files
authored
Merge pull request xnio#142 from iweiss/XNIO-317
[XNIO-317] Introduce API to clean ThreadLocal caches from ByteBufferSlicePool
2 parents 5b41412 + dd76897 commit 2a323dd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

api/src/main/java/org/xnio/ByteBufferSlicePool.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@ public Pooled<ByteBuffer> allocate() {
155155
}
156156
}
157157

158+
/**
159+
* Cleans all ThreadLocal caches
160+
*/
161+
public void clean() {
162+
ThreadLocalCache localCache = localQueueHolder.get();
163+
if (!localCache.queue.isEmpty()) {
164+
localCache.queue.clear();
165+
}
166+
167+
if(!sliceQueue.isEmpty()) {
168+
sliceQueue.clear();
169+
}
170+
}
171+
158172
/**
159173
* Return the size of the {@link ByteBuffer}s that are returned by {@link #allocate()}.
160174
*/

0 commit comments

Comments
 (0)