summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2020-10-04 13:43:15 +0800
committerkeuin <[email protected]>2020-10-04 13:43:15 +0800
commite59bdf4ac0b66ce683be1bbc36852bfce6f70a63 (patch)
tree6c8b97f97af857d2740e7b79d46349cc83a8c7dd /src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java
parentd9c2af035ac2edb68bc8b6a1f94b7c772c3509c8 (diff)
Pump up
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java
index f1a19de..bb0c704 100644
--- a/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java
+++ b/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java
@@ -1,6 +1,10 @@
package com.keuin.kbackupfabric.operation.abstracts;
-public abstract class AbstractAsyncOperation extends AbstractSerializedOperation {
+/**
+ * A basic async operation, but not invokable.
+ * If you want a invokable interface (InvokableOperation), use InvokableAsyncOperation instead.
+ */
+public abstract class AbstractAsyncOperation extends AbstractSerialOperation {
private final Thread thread;
private final String name;
@@ -14,7 +18,7 @@ public abstract class AbstractAsyncOperation extends AbstractSerializedOperation
/**
* Start the worker thread.
*
- * @return true if succeed starting, false if already started.
+ * @return true if succeed starting, false if this operation is already started, or the sync method failed.
*/
@Override
protected final boolean operate() {
@@ -30,13 +34,16 @@ public abstract class AbstractAsyncOperation extends AbstractSerializedOperation
/**
* Implement your async operation here.
- * When this method returns, the operation must finish.
+ * After starting the operation, this method will be run in another thread after the sync method returns.
+ * When this method returns, the operation must have been finished.
*/
protected abstract void async();
/**
* If necessary, implement your sync operations here.
* It will be invoked before starting the async thread.
+ * If this method failed, the async method will not be invoked.
+ * @return whether this method succeed.
*/
protected boolean sync() {
return true;