Skip to content

Commit 44f3451

Browse files
committed
WIP
1 parent e5c5d17 commit 44f3451

14 files changed

Lines changed: 473 additions & 564 deletions

File tree

scijava-ops-engine/src/main/java/org/scijava/ops/engine/matcher/impl/AbstractRichOp.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
import org.scijava.ops.api.RichOp;
3838
import org.scijava.ops.engine.BaseOpHints;
3939
import org.scijava.ops.engine.MatchingConditions;
40-
import org.scijava.progress.Progress;
40+
import org.scijava.progress.ProgressListeners;
41+
import org.scijava.progress.Task;
4142

4243
/**
4344
* An abstract implementation of {@link RichOp}. While this class has <b>no
@@ -90,15 +91,15 @@ public OpInstance<T> instance() {
9091
@Override
9192
public void preprocess(Object... inputs) {
9293
boolean silent = !hints().contains(BaseOpHints.Progress.TRACK);
93-
Progress.register(this, conditions.request().getName(), silent);
94+
ProgressListeners.register(this, conditions.request().getName(), silent);
9495
}
9596

9697
@Override
9798
public void postprocess(Object output) {
9899
if (record) {
99100
env.history().logOutput(this, output);
100101
}
101-
Progress.complete();
102+
ProgressListeners.complete();
102103
}
103104

104105
@Override
@@ -116,4 +117,11 @@ public String toString() {
116117
return instance().toString();
117118
}
118119

120+
private static class OpTask extends Task {
121+
122+
public OpTask(Object progressible, String description, boolean silent)
123+
{
124+
super(progressible, description, silent);
125+
}
126+
}
119127
}

scijava-ops-image/src/main/java/org/scijava/ops/image/adapt/LiftComputersToRAI.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import net.imglib2.util.Intervals;
4141
import org.scijava.function.Computers;
4242
import org.scijava.function.Functions;
43-
import org.scijava.progress.Progress;
43+
import org.scijava.progress.ProgressListeners;
4444
import org.scijava.progress.Task;
4545

4646
import java.util.function.Function;
@@ -73,7 +73,7 @@ private LiftComputersToRAI() {
7373
Computers.Arity1<RAII1, RAIO> lift11(Computers.Arity1<I1, O> computer)
7474
{
7575
return (raiInput1, raiOutput) -> {
76-
Task t = Progress.currentTask();
76+
Task t = ProgressListeners.currentTask();
7777
t.defineTotalProgress(1);
7878
t.setStageMax(Intervals.numElements(raiInput1));
7979
LoopBuilder.setImages(raiInput1, raiOutput).multiThreaded() //
@@ -83,7 +83,7 @@ Computers.Arity1<RAII1, RAIO> lift11(Computers.Arity1<I1, O> computer)
8383
computer.compute(i1, out);
8484
counter.inc();
8585
});
86-
Progress.update(counter.getIntegerLong(), t);
86+
ProgressListeners.update(counter.getIntegerLong(), t);
8787
return null;
8888
});
8989
};

scijava-ops-legacy/src/main/java/org/scijava/legacy/service/DefaultOpEnvironmentService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.scijava.plugin.Attr;
66
import org.scijava.plugin.Parameter;
77
import org.scijava.plugin.Plugin;
8-
import org.scijava.progress.Progress;
8+
import org.scijava.progress.ProgressListeners;
99
import org.scijava.progress.ProgressListener;
1010
import org.scijava.progress.Task;
1111
import org.scijava.script.ScriptService;
@@ -41,7 +41,7 @@ public void initialize() {
4141

4242
// Set up progress, if StatusService available
4343
if (taskService != null) {
44-
Progress.addGlobalListener(new SciJavaProgressListener(taskService));
44+
ProgressListeners.addGlobalListener(new SciJavaProgressListener(taskService));
4545
}
4646
}
4747

scijava-ops-tutorial/src/main/java/org/scijava/ops/tutorial/ReportingProgress.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.scijava.ops.api.OpEnvironment;
3737
import org.scijava.ops.spi.OpCollection;
3838
import org.scijava.ops.spi.OpField;
39-
import org.scijava.progress.Progress;
39+
import org.scijava.progress.ProgressListeners;
4040
import org.scijava.progress.ProgressListener;
4141
import org.scijava.progress.StandardOutputProgressLogger;
4242
import org.scijava.types.Nil;
@@ -45,7 +45,7 @@
4545
* Long-running Ops can be confusing for users. By defining and then reporting
4646
* progress, Ops can tell the user how far it has gotten in the computation.
4747
* <p>
48-
* At the heart of progress reporting is the {@link Progress} class, responsible
48+
* At the heart of progress reporting is the {@link ProgressListeners} class, responsible
4949
* for conveying Ops' progress to users. SciJava Progress defines progress on a
5050
* scale of [0, 1], where:
5151
* <ul>
@@ -54,7 +54,7 @@
5454
* <li>values in between define work in progress</li>
5555
* </ul>
5656
* <p>
57-
* Ops tell the {@link Progress} a few things:
57+
* Ops tell the {@link ProgressListeners} a few things:
5858
* <ol>
5959
* <li>The number of "stages" of computation, including any "subtasks"</li>
6060
* <li>The number of tasks in each stage</li>
@@ -82,15 +82,15 @@ public class ReportingProgress implements OpCollection {
8282
// Define the number of stages, and the number of subtasks
8383
// One stage - finding the primes
8484
// Zero subtasks - we call no other Ops
85-
Progress.defineTotalProgress(1, 0);
85+
ProgressListeners.defineTotalProgress(1, 0);
8686
// Progress is defined within the range [0, 1],
8787
// where 0 denotes an Op that has not yet started.
8888
// and 1 denotes completion.
8989

9090
// setStageMax is used to define the denominator for the Progress fraction.
9191
// If you have N discrete packets of computation, you should call
9292
// Progress.setStageMax(N)
93-
Progress.setStageMax(numPrimes);
93+
ProgressListeners.setStageMax(numPrimes);
9494
// Find each of our primes
9595
while (primes.size() < numPrimes) {
9696
sqrt = (long) Math.sqrt(++val);
@@ -107,7 +107,7 @@ public class ReportingProgress implements OpCollection {
107107
primes.add(val);
108108
// Progress.update() increments the numerator of Progress,
109109
// identifying that one (more) discrete packet of computation is done.
110-
Progress.update();
110+
ProgressListeners.update();
111111
}
112112
}
113113

@@ -124,7 +124,7 @@ public static void main(String... args) {
124124
// To listen to Op progress updates, the ProgressListener must be registered
125125
// through the Progress API. To listen to all Op executions, use the
126126
// following call:
127-
Progress.addGlobalListener(l);
127+
ProgressListeners.addGlobalListener(l);
128128
// If listening to every Op would be overwhelming, the Progress API also
129129
// allows ProgressListeners to be registered for a specific Op, using the
130130
// following call:

0 commit comments

Comments
 (0)