T - the type of the contained resourcepublic class WeakReferenceScopedResource<T> extends Object
ScopedResource backed by a WeakReference. When the resource
is acquired a strong reference is taken and released again on
close(). This allows the object to be reclaimed between usages. In
contrast StrongReferenceScopedResource retains a strong reference for
the lifetime of the wrapper.| Constructor and Description |
|---|
WeakReferenceScopedResource(ScopedThreadLocal<T> scopedThreadLocal,
Supplier<T> supplier) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Signifies the end of the scope and returns the resource to the pool for
use by other acquirers.
|
void |
closeResource()
Close the contained resource and clear any references.
|
T |
get()
Get the contained resource
|
long |
getCreatedTimeNanos()
The time this resource was created
|
@Nullable Class<?> |
getType()
Get the type of object contained, may return null
|
public WeakReferenceScopedResource(ScopedThreadLocal<T> scopedThreadLocal, Supplier<T> supplier)
public T get()
ScopedResourcepublic void close()
ScopedResourceThis method is idempotent; additional invocations have no effect.
close in interface Closeableclose in interface AutoCloseableclose in interface ScopedResource<T>public void closeResource()
Called when a resource is permanently discarded from the pool or when the thread-local stack is closed.
Implementations should release all state and must be idempotent.
@Nullable public @Nullable Class<?> getType()
public long getCreatedTimeNanos()
System.nanoTime() of creationCopyright © 2026 Chronicle Software Ltd. All rights reserved.