public interface IResource
ResourcePool
. Resource
is the default
implementation. IResource
may be used when dealing with hierarchy constraints.
Usage: extend your resource class from Resource
public class myResource
extends Resource {...}
or if you have hierarchy constraints, implement IResource
.
Modifier and Type | Method and Description |
---|---|
boolean |
acquire()
Atomically acquires a free resource.
|
void |
clear()
Cleans the resource of its contents so it can be returned to the pool.
|
boolean |
isAcquired()
An indication if this resource is currently acquired.
|
boolean |
isFromPool()
An indication if this resource originated from the pool or was allocated on the fly.
|
void |
release()
Atomically sets this resource as free; usually when returning a resource to the pool.
|
void |
setAcquired(boolean acquired)
An indication if this resource is acquired.
|
void |
setFromPool(boolean fromPool)
An indication if this resource originated from the pool or was allocated on the fly.
|
boolean isFromPool()
true
if originated from the pool; false
if allocated.void setFromPool(boolean fromPool)
fromPool
- true
if originated from the pool; false
if not part
of the pool.boolean isAcquired()
acquire()
, or by use of it's status indicator setAcquired(boolean)
.true
if resource is acquired. false
if not yet acquired.void setAcquired(boolean acquired)
acquired
- true
if resource is acquired. false
if resource is
not acquired.boolean acquire()
true
if acquire succeeded; false
otherwise (may have
already been acquired by another thread).void release()
Before releasing the resource back into the pool,
is invoked.clear()
RuntimeException
- if this Resource was already free.void clear()
You may use the
isFromPool()
indication to decide of a special action before returning a resource to
the pool, or discard any actions on resources not returning to the pool.
release()
Copyright © GigaSpaces.