Package org.rostore.v2.container.async
Class AsyncStream<S extends AutoCloseable>
java.lang.Object
org.rostore.v2.container.async.AsyncStream<S>
- All Implemented Interfaces:
AutoCloseable,Future<S>
public class AsyncStream<S extends AutoCloseable>
extends Object
implements AutoCloseable, Future<S>
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean b) voidclose()voidempty()voidget()This one will only work if the object is created as blockingbooleanbooleanisDone()voidnotifyRecord(org.rostore.entity.Record record) final voidprocessFunction(AsyncFunction<S> runnable) This function is called from the async process to process the entity.static <S extends AutoCloseable>
AsyncStream<S>wrap(S s) static <S extends AutoCloseable>
AsyncStream<S>wrap(S s, AsyncListener asyncListener) static <S extends AutoCloseable>
AsyncStream<S>wrapBlocking(S s) static <S extends AutoCloseable>
AsyncStream<S>wrapBlocking(S s, AsyncListener asyncListener) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Method Details
-
wrap
-
wrap
-
wrapBlocking
-
wrapBlocking
public static <S extends AutoCloseable> AsyncStream<S> wrapBlocking(S s, AsyncListener asyncListener) -
getException
-
notifyRecord
public void notifyRecord(org.rostore.entity.Record record) -
processFunction
This function is called from the async process to process the entity. This function will safely mark the async process as done and can only be executed once.- Parameters:
runnable- the callback the async process implements
-
fail
-
cancel
public boolean cancel(boolean b) - Specified by:
cancelin interfaceFuture<S extends AutoCloseable>
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<S extends AutoCloseable>
-
isDone
public boolean isDone()- Specified by:
isDonein interfaceFuture<S extends AutoCloseable>
-
get
- Specified by:
getin interfaceFuture<S extends AutoCloseable>
-
get
This one will only work if the object is created as blocking- Specified by:
getin interfaceFuture<S extends AutoCloseable>- Returns:
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
empty
public void empty()
-