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; }
@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; }