AsyncIterator<T>
, AsyncQueue<T>
, BoundedAsyncQueue<T>
@FunctionalInterface public interface AsyncCloseable
Examples of such resources are manually managed memory, open file handles, socket descriptors
etc. While similar to AutoCloseable
, this interface should be used when the resource
release operation may possibly be async. For example, if an object is thread-safe and has many
consumers, an implementation may require all current ongoing operations to complete before
resources are relinquished. A common way to implement this pattern for a thread-safe object with
asynchronous methods is by using an AsyncEpoch
.
May be used with the methods StageSupport.tryWith(AsyncCloseable, Function)
,
StageSupport.tryComposeWith(AsyncCloseable, Function)
to emulate the behavior of a try
with resources block.
Modifier and Type | Method | Description |
---|---|---|
CompletionStage<Void> |
close() |
Relinquishes any resources associated with this object.
|
CompletionStage<Void> close()
CompletionStage
that completes when all resources associated with this object
have been released, or with an exception if the resources cannot be released.Copyright © 2018. All rights reserved.