public class ThreadLocalCachingAllocator extends CachingAllocator
ByteBuffer
allocations. It
provides the same functionality as the CachingAllocator
but to
eliminate latency issues in multi-thread application it uses
FastThreadLocal
to store more sets of caches so each supported thread
will have its own separate set.
By default it supports only threads implementing the
IFastThreadLocalThread
interface. For other threads it uses one
shared set of caches as in the CachingAllocator
. To extend the
support for all threads use the constructor with the forAllThreads
argument.
DEFAULT, direct
Constructor and Description |
---|
ThreadLocalCachingAllocator(boolean direct)
Constructs a thread-local caching allocator with default minimal capacity
(128).
|
ThreadLocalCachingAllocator(boolean direct,
IDefaultAllocatorMetricCollector metric)
Constructs a thread-local caching allocator with default minimal capacity
(128) and specified metric data collector.
|
ThreadLocalCachingAllocator(boolean direct,
int minCapacity)
Constructs a thread-local caching allocator.
|
ThreadLocalCachingAllocator(boolean direct,
int minCapacity,
boolean forAllThreads,
IDefaultAllocatorMetricCollector metric)
Constructs a thread-local caching allocator supporting all types of threads
threads.
|
ThreadLocalCachingAllocator(boolean direct,
int minCapacity,
IDefaultAllocatorMetricCollector metric)
Constructs a thread-local caching allocator with specified metric data
collector.
|
Modifier and Type | Method and Description |
---|---|
void |
purge()
Purges all caches used by this allocator for the current thread.
|
allocate, allocate, allocateEmpty, getMinCapacity, isReleasable, release
allocate, ensure, ensureSome, extend, reduce, usesArray
public ThreadLocalCachingAllocator(boolean direct, IDefaultAllocatorMetricCollector metric)
direct
- true
if the allocator should allocate direct
buffers, or false
to allocate non-direct buffers
that have a backing arraymetric
- a metric data collectorpublic ThreadLocalCachingAllocator(boolean direct)
direct
- true
if the allocator should allocate direct
buffers, or false
to allocate non-direct buffers
that have a backing arraypublic ThreadLocalCachingAllocator(boolean direct, int minCapacity, IDefaultAllocatorMetricCollector metric)
direct
- true
if the allocator should allocate direct
buffers, or false
to allocate non-direct
buffers that have a backing arrayminCapacity
- the minimal capacity for buffers allocated by this
allocatormetric
- a metric data collectorpublic ThreadLocalCachingAllocator(boolean direct, int minCapacity)
direct
- true
if the allocator should allocate direct
buffers, or false
to allocate non-direct
buffers that have a backing arrayminCapacity
- the minimal capacity for buffers allocated by this
allocatorpublic ThreadLocalCachingAllocator(boolean direct, int minCapacity, boolean forAllThreads, IDefaultAllocatorMetricCollector metric)
direct
- true
if the allocator should allocate
direct buffers, or false
to allocate
non-direct buffers that have a backing arrayminCapacity
- the minimal capacity for buffers allocated by this
allocatorforAllThreads
- determines if the allocator should support all types of
threadsmetric
- a metric data collectorpublic void purge()
purge
in class CachingAllocator
Copyright © 2017–2022 SNF4J.ORG. All rights reserved.