T
- the type of resource this pool managespublic interface Pool<T> extends Closeable
Modifier and Type | Method and Description |
---|---|
T |
acquire()
Acquires a resource from the pool.
|
T |
acquire(long time,
TimeUnit unit)
Acquires a resource from the pool.
|
default PooledResource<T> |
acquireCloseable()
Acquires a resource wrapped inside a
PooledResource , which will release
the resource to this pool when it's closed. |
default PooledResource<T> |
acquireCloseable(long time,
TimeUnit unit)
Acquires a resource wrapped inside a
PooledResource , which will release
the resource to this pool when it's closed. |
void |
release(T resource)
Releases the resource to the pool.
|
int |
size() |
T acquire() throws IOException
IOException
T acquire(long time, TimeUnit unit) throws TimeoutException, IOException
time
- time it takes before timeout if no resource is availableunit
- the unit of the timeTimeoutException
IOException
default PooledResource<T> acquireCloseable() throws IOException
PooledResource
, which will release
the resource to this pool when it's closed.IOException
default PooledResource<T> acquireCloseable(long time, TimeUnit unit) throws TimeoutException, IOException
PooledResource
, which will release
the resource to this pool when it's closed.time
- time it takes before timeout if no resource is availableunit
- the unit of the timeTimeoutException
IOException
void release(T resource)
resource
- the resource to releaseint size()
Copyright © 2023. All Rights Reserved.