Skip to content

Commit

Permalink
chore: update assettype
Browse files Browse the repository at this point in the history
  • Loading branch information
pollend committed Aug 1, 2021
1 parent b2c766e commit 305644f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ public final <U extends Asset<T>> Optional<U> createInstance() {

/**
* return the non-instanced version of this asset. if the asset is already the normal
* type then it returns itself.
* type then it returns itself. instanced assets are temporary copies from the normal loaded instances.
*
* @return non-instanced version of this Asset
*/
public final Asset<T> getConcreteAsset() {
public final Asset<T> getNormalAsset() {
if (parent == null) {
return this;
}
Expand All @@ -187,7 +188,6 @@ public final synchronized void dispose() {
if (!disposed) {
compactInstances();
disposed = true;
assetType.onAssetDisposed(this);
disposalHook.dispose();
if (parent == null) {
for (WeakReference<Asset<T>> inst : this.instances()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,13 @@ public synchronized void close() {
*/
@SuppressWarnings("unchecked")
public void processDisposal() {
Reference<? extends Asset<U>> ref = disposalQueue.poll();
Set<ResourceUrn> urns = new HashSet<>();
while (ref != null) {
Reference<? extends Asset<U>> ref = null;
while ((ref = disposalQueue.poll()) != null) {
AssetReference<? extends Asset<U>> assetRef = (AssetReference<? extends Asset<U>>) ref;
urns.add(assetRef.parentUrn);
assetRef.dispose();
references.remove(assetRef);
ref = disposalQueue.poll();
}
for (ResourceUrn urn : urns) {
disposeAsset(urn);
Expand Down Expand Up @@ -261,17 +260,6 @@ synchronized void registerAsset(Asset<U> asset, DisposalHook disposer) {
}
}

/**
* Notifies the asset type when an asset is disposed
*
* @param asset The asset that was disposed.
*/
void onAssetDisposed(Asset<U> asset) {
if (!asset.getUrn().isInstance()) {
disposeAsset(asset.getUrn());
}
}

/**
* dispose asset and remove loaded asset from {@link #loadedAssets}
* @param target urn to free
Expand Down

0 comments on commit 305644f

Please sign in to comment.