R
- the type of the resourcestatic class PoolMap.ThreadLocalPool<R> extends Object implements PoolMap.Pool<R>
ThreadLocalPool
represents a PoolMap.Pool
that works similarly to
ThreadLocal
class. It essentially binds the resource to the thread from which it is
accessed. It doesn't remove resources when a thread exits, those resources must be closed
manually.
Note that the size of the pool is essentially bounded by the number of threads that add resources to this pool.
Constructor and Description |
---|
ThreadLocalPool() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
R |
getOrCreate(PoolMap.PoolResourceSupplier<R> supplier) |
boolean |
remove(R resource) |
int |
size() |
Collection<R> |
values() |
public ThreadLocalPool()
public R getOrCreate(PoolMap.PoolResourceSupplier<R> supplier) throws IOException
getOrCreate
in interface PoolMap.Pool<R>
IOException
public boolean remove(R resource)
remove
in interface PoolMap.Pool<R>
public int size()
size
in interface PoolMap.Pool<R>
public void clear()
clear
in interface PoolMap.Pool<R>
public Collection<R> values()
values
in interface PoolMap.Pool<R>
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.