Skip to content

Commit

Permalink
Rename Completion::wrap to toRun
Browse files Browse the repository at this point in the history
  • Loading branch information
fluentfuture committed Jan 12, 2025
1 parent 1fb28ec commit 660fcd7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ final class Completion implements AutoCloseable {
private final Phaser phaser = new Phaser(1);

void run(Runnable task) {
wrap(task).run();
toRun(task).run();
}

Runnable wrap(Runnable task) {
Runnable toRun(Runnable task) {
phaser.register();
return () -> {
try {
Expand Down
8 changes: 4 additions & 4 deletions mug/src/main/java/com/google/mu/util/concurrent/Fanout.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,17 +481,17 @@ Scope add(Runnable... tasks) {
}

void run() throws StructuredConcurrencyInterruptedException {
try (Completion completion = new Completion()){
withUnlimitedConcurrency().parallelize(runnables.stream().map(completion::wrap));
try (Completion completion = new Completion()) {
withUnlimitedConcurrency().parallelize(runnables.stream().map(completion::toRun));
} catch (InterruptedException e) {
throw new StructuredConcurrencyInterruptedException(e);
}
}

@Deprecated
void runUninterruptibly() {
try (Completion completion = new Completion()){
withUnlimitedConcurrency().parallelizeUninterruptibly(runnables.stream().map(completion::wrap));
try (Completion completion = new Completion()) {
withUnlimitedConcurrency().parallelizeUninterruptibly(runnables.stream().map(completion::toRun));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CompletionTest {
AtomicBoolean done = new AtomicBoolean();
try (Completion completion = new Completion()) {
completion.run(() -> {});
new Thread(completion.wrap(() -> {
new Thread(completion.toRun(() -> {
done.set(true);
})).start();
}
Expand All @@ -46,7 +46,7 @@ public class CompletionTest {
@Test public void twoTasks_failed() throws Exception {
AtomicBoolean done = new AtomicBoolean();
try (Completion completion = new Completion()) {
new Thread(completion.wrap(() -> {
new Thread(completion.toRun(() -> {
done.set(true);
})).start();
completion.run(() -> {
Expand Down

0 comments on commit 660fcd7

Please sign in to comment.