Package org.greenrobot.greendao.async
Class AsyncOperation
- java.lang.Object
-
- org.greenrobot.greendao.async.AsyncOperation
-
public class AsyncOperation extends java.lang.ObjectAn operation that will be enqueued for asynchronous execution.- See Also:
AsyncSession
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAsyncOperation.OperationType
-
Field Summary
Fields Modifier and Type Field Description static intFLAG_MERGE_TXstatic intFLAG_STOP_QUEUE_ON_EXCEPTIONTODO unused, just an ideastatic intFLAG_TRACK_CREATOR_STACKTRACE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ExceptiongetCreatorStacktrace()The stacktrace is captured using an exception ifFLAG_TRACK_CREATOR_STACKTRACEwas used (null otherwise).longgetDuration()intgetMergedOperationsCount()If this operation was successfully merged with other operation into a single TX, this will give the count of merged operations.java.lang.ObjectgetParameter()java.lang.ObjectgetResult()The operation's result after it has completed.intgetSequenceNumber()Each operation get a unique sequence number when the operation is enqueued.java.lang.ThrowablegetThrowable()longgetTimeCompleted()longgetTimeStarted()AsyncOperation.OperationTypegetType()booleanisCompleted()booleanisCompletedSucessfully()booleanisFailed()booleanisMergeTx()voidsetThrowable(java.lang.Throwable throwable)java.lang.ObjectwaitForCompletion()Waits until the operation is complete.booleanwaitForCompletion(int maxMillis)Waits until the operation is complete, but at most the given amount of milliseconds.If the thread gets interrupted, anyInterruptedExceptionwill be rethrown as aDaoException.
-
-
-
Field Detail
-
FLAG_MERGE_TX
public static final int FLAG_MERGE_TX
- See Also:
- Constant Field Values
-
FLAG_STOP_QUEUE_ON_EXCEPTION
public static final int FLAG_STOP_QUEUE_ON_EXCEPTION
TODO unused, just an idea- See Also:
- Constant Field Values
-
FLAG_TRACK_CREATOR_STACKTRACE
public static final int FLAG_TRACK_CREATOR_STACKTRACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getThrowable
public java.lang.Throwable getThrowable()
-
setThrowable
public void setThrowable(java.lang.Throwable throwable)
-
getType
public AsyncOperation.OperationType getType()
-
getParameter
public java.lang.Object getParameter()
-
getResult
public java.lang.Object getResult()
The operation's result after it has completed. Waits until a result is available.- Returns:
- The operation's result or null if the operation type does not produce any result.
- See Also:
waitForCompletion()
-
isMergeTx
public boolean isMergeTx()
- Returns:
- true if this operation may be merged with others into a single database transaction.
-
getTimeStarted
public long getTimeStarted()
-
getTimeCompleted
public long getTimeCompleted()
-
getDuration
public long getDuration()
-
isFailed
public boolean isFailed()
-
isCompleted
public boolean isCompleted()
-
waitForCompletion
public java.lang.Object waitForCompletion()
Waits until the operation is complete. If the thread gets interrupted, anyInterruptedExceptionwill be rethrown as aDaoException.- Returns:
- Result if any, see
getResult()
-
waitForCompletion
public boolean waitForCompletion(int maxMillis)
Waits until the operation is complete, but at most the given amount of milliseconds.If the thread gets interrupted, anyInterruptedExceptionwill be rethrown as aDaoException.- Returns:
- true if the operation completed in the given time frame.
-
isCompletedSucessfully
public boolean isCompletedSucessfully()
-
getMergedOperationsCount
public int getMergedOperationsCount()
If this operation was successfully merged with other operation into a single TX, this will give the count of merged operations. If the operation was not merged, it will be 0.
-
getSequenceNumber
public int getSequenceNumber()
Each operation get a unique sequence number when the operation is enqueued. Can be used for efficiently identifying/mapping operations.
-
getCreatorStacktrace
public java.lang.Exception getCreatorStacktrace()
The stacktrace is captured using an exception ifFLAG_TRACK_CREATOR_STACKTRACEwas used (null otherwise).
-
-