public final class SharedResources extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
SharedResources.ResourceAndSize<T extends AutoCloseable>
A resource handle with size.
|
Constructor and Description |
---|
SharedResources() |
Modifier and Type | Method and Description |
---|---|
<T extends AutoCloseable> |
getOrAllocateSharedResource(String type,
Object leaseHolder,
LongFunctionWithException<T,Exception> initializer,
long sizeForInitialization)
Gets the shared memory resource for the given owner and registers a lease.
|
void |
release(String type,
Object leaseHolder,
LongConsumer releaser)
Releases a lease (identified by the lease holder object) for the given type.
|
public <T extends AutoCloseable> SharedResources.ResourceAndSize<T> getOrAllocateSharedResource(String type, Object leaseHolder, LongFunctionWithException<T,Exception> initializer, long sizeForInitialization) throws Exception
The resource must be released when no longer used. That releases the lease. When all leases are released, the resource is disposed.
Exception
public void release(String type, Object leaseHolder, LongConsumer releaser) throws Exception
This method takes an additional hook that is called when the resource is disposed.
Exception
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.