Package org.apache.hadoop.hbase.util
Class PoolMap.ThreadLocalPool<R>
java.lang.Object
org.apache.hadoop.hbase.util.PoolMap.ThreadLocalPool<R>
- Type Parameters:
R
- the type of the resource
- All Implemented Interfaces:
PoolMap.Pool<R>
The
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.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
getOrCreate
(PoolMap.PoolResourceSupplier<R> supplier) boolean
int
size()
values()
-
Field Details
-
resources
-
-
Constructor Details
-
ThreadLocalPool
public ThreadLocalPool()
-
-
Method Details
-
getOrCreate
- Specified by:
getOrCreate
in interfacePoolMap.Pool<R>
- Throws:
IOException
-
remove
- Specified by:
remove
in interfacePoolMap.Pool<R>
-
size
- Specified by:
size
in interfacePoolMap.Pool<R>
-
clear
- Specified by:
clear
in interfacePoolMap.Pool<R>
-
values
- Specified by:
values
in interfacePoolMap.Pool<R>
-