Skip to content

Commit

Permalink
Apply scijava-formatter
Browse files Browse the repository at this point in the history
NB: the class-level javadoc was skipped. See:
scijava/scijava-coding-style#4
  • Loading branch information
hinerm committed Apr 7, 2022
1 parent 0bac953 commit 6e431dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/main/java/org/scijava/task/DefaultTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class DefaultTask implements Task {
* reported.
*/
public DefaultTask(final ThreadService threadService,
final EventService eventService)
final EventService eventService)
{
this.threadService = threadService;
this.eventService = eventService;
Expand Down Expand Up @@ -123,7 +123,7 @@ public void start() {
// - Synchronous
@Override
public void finish() {
isDone=true;
isDone = true;
fireTaskEvent();
}

Expand Down Expand Up @@ -176,12 +176,12 @@ public boolean isCanceled() {
public void cancel(final String reason) {
canceled = true;
cancelReason = reason;
if (cancelCallBack!=null) cancelCallBack.run();
if (cancelCallBack != null) cancelCallBack.run();
fireTaskEvent();
}

void defaultCancelCallback() {
if (future!=null) {
if (future != null) {
isDone = future.cancel(true);
}
}
Expand Down Expand Up @@ -231,9 +231,11 @@ private synchronized void initFuture(final Runnable r) {
try {
fireTaskEvent(); // Triggers an event just before the task is executed
r.run();
} finally {
}
finally {
isDone = true;
fireTaskEvent(); // Triggers an event just after the task has successfully completed or failed
fireTaskEvent(); // Triggers an event just after the task has
// successfully completed or failed
}
});
}
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/org/scijava/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,18 @@ default void finish() {}
* If the task is cancelled (external call to {@link Task#cancel(String)}),
* the input runnable argument should be executed by task implementors.
*
* @param runnable : should be executed if this task is cancelled through {@link Task#cancel(String)}
* @param runnable : should be executed if this task is cancelled through
* {@link Task#cancel(String)}
*/
default void setCancelCallBack(Runnable runnable) {}

/**
* Returns the current cancel callback runnable,
* This can be used to concatenate callbacks in order,
* for instance, to ask for a user confirmation before cancelling the task
* Returns the current cancel callback runnable, This can be used to
* concatenate callbacks in order, for instance, to ask for a user
* confirmation before cancelling the task
*/
default Runnable getCancelCallBack() { return () -> {}; }
default Runnable getCancelCallBack() {
return () -> {};
}

}
1 change: 1 addition & 0 deletions src/test/java/org/scijava/task/TaskServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/

package org.scijava.task;

import static org.junit.Assert.assertEquals;
Expand Down

0 comments on commit 6e431dd

Please sign in to comment.