From e59bdf4ac0b66ce683be1bbc36852bfce6f70a63 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sun, 4 Oct 2020 13:43:15 +0800 Subject: Pump up --- .../operation/abstracts/AbstractAsyncOperation.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java') 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; -- cgit v1.2.3