@Override public final void destroy(DeviceResourceDescriptor descriptor) { // If the map is empty (null) then there are no resources to dispose if (map == null) { return; } // Find the existing resource RefCount count = map.get(descriptor); if (count != null) { // If the resource exists, decrement the reference count. count.count--; if (count.count == 0) { // If this was the last reference, deallocate it. deallocate(count.resource, descriptor); map.remove(descriptor); } } // Null out the map when empty to save a small amount of memory if (map.isEmpty()) { map = null; } }
public void dispose() { super.dispose(); if (missingImage != null) { // RAP [bm]: Image#dispose // missingImage.dispose(); // RAPEND: [bm] missingImage = null; } } }
public final Object create(DeviceResourceDescriptor descriptor) throws DeviceResourceException { // Lazily allocate the map if (map == null) { map = new HashMap(); } // Get the current reference count RefCount count = (RefCount)map.get(descriptor); if (count != null) { // If this resource already exists, increment the reference count and return // the existing resource. count.count++; return count.resource; } // Allocate and return a new resource (with ref count = 1) Object resource = allocate(descriptor); count = new RefCount(resource); map.put(descriptor, count); return resource; }
@Override public final Object create(DeviceResourceDescriptor descriptor) throws DeviceResourceException { // Lazily allocate the map if (map == null) { map = new HashMap<>(); } // Get the current reference count RefCount count = map.get(descriptor); if (count != null) { // If this resource already exists, increment the reference count and return // the existing resource. count.count++; return count.resource; } // Allocate and return a new resource (with ref count = 1) Object resource = allocate(descriptor); count = new RefCount(resource); map.put(descriptor, count); return resource; }
public final void destroy(DeviceResourceDescriptor descriptor) { // If the map is empty (null) then there are no resources to dispose if (map == null) { return; } // Find the existing resource RefCount count = (RefCount)map.get(descriptor); if (count != null) { // If the resource exists, decrement the reference count. count.count--; if (count.count == 0) { // If this was the last reference, deallocate it. deallocate(count.resource, descriptor); map.remove(descriptor); } } // Null out the map when empty to save a small amount of memory if (map.isEmpty()) { map = null; } }
@Override public void dispose() { super.dispose(); if (missingImage != null) { missingImage.dispose(); missingImage = null; } } }
@Override public final Object create(DeviceResourceDescriptor descriptor) throws DeviceResourceException { // Lazily allocate the map if (map == null) { map = new HashMap<>(); } // Get the current reference count RefCount count = map.get(descriptor); if (count != null) { // If this resource already exists, increment the reference count and return // the existing resource. count.count++; return count.resource; } // Allocate and return a new resource (with ref count = 1) Object resource = allocate(descriptor); count = new RefCount(resource); map.put(descriptor, count); return resource; }
@Override public final void destroy(DeviceResourceDescriptor descriptor) { // If the map is empty (null) then there are no resources to dispose if (map == null) { return; } // Find the existing resource RefCount count = map.get(descriptor); if (count != null) { // If the resource exists, decrement the reference count. count.count--; if (count.count == 0) { // If this was the last reference, deallocate it. deallocate(count.resource, descriptor); map.remove(descriptor); } } // Null out the map when empty to save a small amount of memory if (map.isEmpty()) { map = null; } }
@Override public void dispose() { super.dispose(); if (missingImage != null) { missingImage.dispose(); missingImage = null; } } }
/** * Deallocates any resources allocated by this registry that have not yet been * deallocated. * * @since 1.0 */ public void dispose() { super.dispose(); if (map == null) { return; } Collection entries = map.entrySet(); for (Iterator iter = entries.iterator(); iter.hasNext();) { Map.Entry next = (Map.Entry) iter.next(); Object key = next.getKey(); RefCount val = (RefCount)next.getValue(); deallocate(val.resource, (DeviceResourceDescriptor)key); } map = null; }
/** * Deallocates any resources allocated by this registry that have not yet been * deallocated. * * @since 3.1 */ @Override public void dispose() { super.dispose(); if (map == null) { return; } Collection<Entry<DeviceResourceDescriptor, RefCount>> entries = map.entrySet(); for (Entry<DeviceResourceDescriptor, RefCount> next : entries) { Object key = next.getKey(); RefCount val = next.getValue(); deallocate(val.resource, (DeviceResourceDescriptor)key); } map = null; }
/** * Deallocates any resources allocated by this registry that have not yet been * deallocated. * * @since 3.1 */ @Override public void dispose() { super.dispose(); if (map == null) { return; } Collection<Entry<DeviceResourceDescriptor, RefCount>> entries = map.entrySet(); for (Iterator<Entry<DeviceResourceDescriptor, RefCount>> iter = entries.iterator(); iter.hasNext();) { Entry<DeviceResourceDescriptor, RefCount> next = iter.next(); Object key = next.getKey(); RefCount val = next.getValue(); deallocate(val.resource, (DeviceResourceDescriptor)key); } map = null; }