Top Description Inners Fields Constructors Methods
com.sun.prism.impl

public abstract Class BaseResourcePool<T>

extends Object
implements ResourcePool<T>
Class Inheritance
All Implemented Interfaces
com.sun.prism.impl.ResourcePool
Known Direct Subclasses
com.sun.prism.j2d.J2DTexturePool, com.sun.prism.sw.SWTexturePool, com.sun.prism.null3d.DummyTexturePool, com.sun.prism.d3d.D3DVramPool, com.sun.prism.es2.ES2VramPool
Type Parameters
<T>
the type of objects stored in this resource pool
Imports
java.lang.ref.WeakReference

The base implementation of the ResourcePool interface, providing bookkeeping for the managed() method and support for sharing resources amongst multiple pools.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv long
private static final int
pack-priv long
private final Thread
pack-priv final long
pack-priv final long
private static final int
private static final int
private BaseResourcePool.WeakLinkedList<T>
pack-priv final ResourcePool<T>
private static final String[]
private static final BaseResourcePool.Predicate[]

Constructor Summary

AccessConstructor and Description
protected
BaseResourcePool(long target, long max)

protected
protected
BaseResourcePool(ResourcePool<T> parent, long target, long max)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

boolean indicating if the requested space is now available
cleanup
(long needed)

Clean up the resources in the indicated pool using a standard algorithm until at least the specified amount of resource units have been reclaimed.

private void
pack-priv static String
commas(long v)

public void
freeDisposalRequestedAndCheckResources(boolean
true if the caller wishes to forgive and unlock all outstanding locks on non-permanent resources
forgiveStaleLocks
)

Implements com.sun.prism.impl.ResourcePool.freeDisposalRequestedAndCheckResources.

Check that all resources are in the correct state for an idle condition and free any resources which were disposed from a non-resource thread.

public boolean
isManagerThread()

Implements com.sun.prism.impl.ResourcePool.isManagerThread.

True if Thread.currentThread() is a thread that created this ResourcePool

public final long
managed()

Implements com.sun.prism.impl.ResourcePool.managed.

The amount of this resource currently being used to hold managed resources.

public final long
max()

Implements com.sun.prism.impl.ResourcePool.max.

The total space available in this pool for allocating any kind of resource, even unmanaged resources, and including those resources already allocated.

public final long
origTarget()

Implements com.sun.prism.impl.ResourcePool.origTarget.

The initial target of the maximum amount of space in this resource pool that should be used so as to be friendly to other parts of the system.

public boolean
prepareForAllocation(long
the size of the resource that is about to be allocated
size
)

Implements com.sun.prism.impl.ResourcePool.prepareForAllocation.

Prepare for an allocation of a resource from this pool of the indicated size by freeing up uninteresting resources until the allocation fits within the target() or max() sizes.

private static void
printpoolpercent(int stat, int total, String desc)

public void
printSummary(boolean printlocksources)

private void
pruneLastChance(boolean desperate)

public final void
recordAllocated(long
the amount of the resource to be indicated as managed.
size
)

Implements com.sun.prism.impl.ResourcePool.recordAllocated.

Record the indicated amount of the resource as being allocated for a ManagedResource.

public final void
recordFree(long
the amount of the resource to remove from the managed amount.
size
)

Implements com.sun.prism.impl.ResourcePool.recordFree.

Record the indicated amount of the resource as no longer being held in a ManagedResource.

public final void
resourceFreed(ManagedResource<T>
the resource that is freed, no longer being managed
freed
)

Implements com.sun.prism.impl.ResourcePool.resourceFreed.

Record the ManagedResource object as no longer being managed by this pool.

public final void
resourceManaged(ManagedResource<T>
the resource that is now being managed
mr
)

Implements com.sun.prism.impl.ResourcePool.resourceManaged.

Record the ManagedResource object as being currently managed by this pool.

public final void
setTarget(long
the new current target to be set
newTarget
)

Implements com.sun.prism.impl.ResourcePool.setTarget.

Sets a new current target of the maximum amount of space in this resource pool that should be used so as to be friendly to other parts of the system.

public final long
target()

Implements com.sun.prism.impl.ResourcePool.target.

The current target of the maximum amount of space in this resource pool that should be used so as to be friendly to other parts of the system.

public long
used()

Implements com.sun.prism.impl.ResourcePool.used.

The amount of a resource currently being used to hold any kind of resource, whether managed or not.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

curTargetback to summary
pack-priv long curTarget
FOREVERback to summary
private static final int FOREVER
managedSizeback to summary
pack-priv long managedSize
managerThreadback to summary
private final Thread managerThread
maxSizeback to summary
pack-priv final long maxSize
origTargetback to summary
pack-priv final long origTarget
RECENTback to summary
private static final int RECENT
RECENTLY_USEFULback to summary
private static final int RECENTLY_USEFUL
resourceHeadback to summary
private BaseResourcePool.WeakLinkedList<T> resourceHead
sharedParentback to summary
pack-priv final ResourcePool<T> sharedParent
stageReasonsback to summary
private static final String[] stageReasons
stageTestersback to summary
private static final BaseResourcePool.Predicate[] stageTesters

Constructor Detail

BaseResourcePoolback to summary
protected BaseResourcePool(long target, long max)
BaseResourcePoolback to summary
protected BaseResourcePool(ResourcePool<T> parent)
BaseResourcePoolback to summary
protected BaseResourcePool(ResourcePool<T> parent, long target, long max)

Method Detail

cleanupback to summary
public boolean cleanup(long needed)

Clean up the resources in the indicated pool using a standard algorithm until at least the specified amount of resource units have been reclaimed. The standard algorithm uses the following stages until it obtains enough room in the pool:

  1. Prune any resources which are already free, but have not been accounted for yet.
  2. Go through a few passes cleaning out any non-interesting resources that have not been used in a long time with decreasing cutoff limits for the maximum age of the resource.
  3. Go through more passes cleaning out even interesting resources that have not been used in a fairly long time with decreasing age limits.
  4. Attempt to grow the target to accommodate the new request.
  5. Finally, prune any resources that are not currently in the process of being used (i.e. locked or permanent).
Returns:boolean

boolean indicating if the requested space is now available

cleanupback to summary
private void cleanup(BaseResourcePool.Predicate predicate)
commasback to summary
pack-priv static String commas(long v)
freeDisposalRequestedAndCheckResourcesback to summary
public void freeDisposalRequestedAndCheckResources(boolean forgiveStaleLocks)

Implements com.sun.prism.impl.ResourcePool.freeDisposalRequestedAndCheckResources.

Check that all resources are in the correct state for an idle condition and free any resources which were disposed from a non-resource thread. This method must be called on a thread that is appropriate for disposing and managing resources for the resource pools. The boolean forgiveStaleLocks parameter is used to indicate that an exceptional condition occurred which caused the caller to abort a cycle of resource usage, potentially with outstanding resource locks. This method will unlock all non-permanent resources that have outstanding locks if forgiveStaleLocks is true, or it will print out a warning and a resource summary if that parameter is false.

Parameters
forgiveStaleLocks:boolean

true if the caller wishes to forgive and unlock all outstanding locks on non-permanent resources

Annotations
@Override
isManagerThreadback to summary
public boolean isManagerThread()

Implements com.sun.prism.impl.ResourcePool.isManagerThread.

Doc from com.sun.prism.impl.ResourcePool.isManagerThread.

True if Thread.currentThread() is a thread that created this ResourcePool

Returns:boolean

true if Thread.currentThread() is a thread that created this ResourcePool

Annotations
@Override
managedback to summary
public final long managed()

Implements com.sun.prism.impl.ResourcePool.managed.

Doc from com.sun.prism.impl.ResourcePool.managed.

The amount of this resource currently being used to hold managed resources. This amount may be less than the amount returned by the used() method if the pool is shared amongst other resources.

Returns:long

the amount being used to hold managed resources

Annotations
@Override
maxback to summary
public final long max()

Implements com.sun.prism.impl.ResourcePool.max.

Doc from com.sun.prism.impl.ResourcePool.max.

The total space available in this pool for allocating any kind of resource, even unmanaged resources, and including those resources already allocated.

Returns:long

the maximum amount of the resource

Annotations
@Override
origTargetback to summary
public final long origTarget()

Implements com.sun.prism.impl.ResourcePool.origTarget.

Doc from com.sun.prism.impl.ResourcePool.origTarget.

The initial target of the maximum amount of space in this resource pool that should be used so as to be friendly to other parts of the system. This number must be less than or equal to the amount returned by the max() method.

Returns:long

the initial target amount of the resource to be used

Annotations
@Override
prepareForAllocationback to summary
public boolean prepareForAllocation(long size)

Implements com.sun.prism.impl.ResourcePool.prepareForAllocation.

Doc from com.sun.prism.impl.ResourcePool.prepareForAllocation.

Prepare for an allocation of a resource from this pool of the indicated size by freeing up uninteresting resources until the allocation fits within the target() or max() sizes.

Parameters
size:long

the size of the resource that is about to be allocated

Returns:boolean

true if there is room for the indicated resource

Annotations
@Override
printpoolpercentback to summary
private static void printpoolpercent(int stat, int total, String desc)
printSummaryback to summary
public void printSummary(boolean printlocksources)
pruneLastChanceback to summary
private void pruneLastChance(boolean desperate)
recordAllocatedback to summary
public final void recordAllocated(long size)

Implements com.sun.prism.impl.ResourcePool.recordAllocated.

Doc from com.sun.prism.impl.ResourcePool.recordAllocated.

Record the indicated amount of the resource as being allocated for a ManagedResource.

Parameters
size:long

the amount of the resource to be indicated as managed.

Annotations
@Override
recordFreeback to summary
public final void recordFree(long size)

Implements com.sun.prism.impl.ResourcePool.recordFree.

Doc from com.sun.prism.impl.ResourcePool.recordFree.

Record the indicated amount of the resource as no longer being held in a ManagedResource.

Parameters
size:long

the amount of the resource to remove from the managed amount.

Annotations
@Override
resourceFreedback to summary
public final void resourceFreed(ManagedResource<T> freed)

Implements com.sun.prism.impl.ResourcePool.resourceFreed.

Doc from com.sun.prism.impl.ResourcePool.resourceFreed.

Record the ManagedResource object as no longer being managed by this pool.

Parameters
freed:ManagedResource<T>

the resource that is freed, no longer being managed

Annotations
@Override
resourceManagedback to summary
public final void resourceManaged(ManagedResource<T> mr)

Implements com.sun.prism.impl.ResourcePool.resourceManaged.

Doc from com.sun.prism.impl.ResourcePool.resourceManaged.

Record the ManagedResource object as being currently managed by this pool.

Parameters
mr:ManagedResource<T>

the resource that is now being managed

Annotations
@Override
setTargetback to summary
public final void setTarget(long newTarget)

Implements com.sun.prism.impl.ResourcePool.setTarget.

Doc from com.sun.prism.impl.ResourcePool.setTarget.

Sets a new current target of the maximum amount of space in this resource pool that should be used so as to be friendly to other parts of the system. The specified newTarget number must be less than or equal to the amount returned by the max() method, larger than the amount returned by the origTarget() method.

Parameters
newTarget:long

the new current target to be set

Annotations
@Override
targetback to summary
public final long target()

Implements com.sun.prism.impl.ResourcePool.target.

Doc from com.sun.prism.impl.ResourcePool.target.

The current target of the maximum amount of space in this resource pool that should be used so as to be friendly to other parts of the system. This number must be less than or equal to the amount returned by the max() method, larger than the amount returned by the origTarget() method, and may change over time.

Returns:long

the current target amount of the resource to be used

Annotations
@Override
usedback to summary
public long used()

Implements com.sun.prism.impl.ResourcePool.used.

Doc from com.sun.prism.impl.ResourcePool.used.

The amount of a resource currently being used to hold any kind of resource, whether managed or not.

Returns:long

the amount being used

Annotations
@Override
com.sun.prism.impl back to summary

pack-priv Interface BaseResourcePool.Predicate


Method Summary

Modifier and TypeMethod and Description
public boolean

Method Detail

testback to summary
public boolean test(ManagedResource<?> mr)
com.sun.prism.impl back to summary

pack-priv Class BaseResourcePool.WeakLinkedList<T>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv BaseResourcePool.WeakLinkedList<T>
pack-priv final long
pack-priv final WeakReference<ManagedResource<T>>

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv ManagedResource<T>
pack-priv void
insert(ManagedResource<T> mresource, long size)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nextback to summary
pack-priv BaseResourcePool.WeakLinkedList<T> next
sizeback to summary
pack-priv final long size
theResourceRefback to summary
pack-priv final WeakReference<ManagedResource<T>> theResourceRef

Constructor Detail

WeakLinkedListback to summary
pack-priv WeakLinkedList()
WeakLinkedListback to summary
pack-priv WeakLinkedList(ManagedResource<T> mresource, long size, BaseResourcePool.WeakLinkedList<T> next)

Method Detail

getResourceback to summary
pack-priv ManagedResource<T> getResource()
insertback to summary
pack-priv void insert(ManagedResource<T> mresource, long size)