From 660fcd798fac1829d809f441152f6f1c0fcb6bb7 Mon Sep 17 00:00:00 2001 From: Ben Yu Date: Sat, 11 Jan 2025 17:22:18 -0800 Subject: [PATCH] Rename Completion::wrap to toRun --- .../java/com/google/mu/util/concurrent/Completion.java | 4 ++-- .../main/java/com/google/mu/util/concurrent/Fanout.java | 8 ++++---- .../com/google/mu/util/concurrent/CompletionTest.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mug/src/main/java/com/google/mu/util/concurrent/Completion.java b/mug/src/main/java/com/google/mu/util/concurrent/Completion.java index 5c5ae7320..f46b6e460 100644 --- a/mug/src/main/java/com/google/mu/util/concurrent/Completion.java +++ b/mug/src/main/java/com/google/mu/util/concurrent/Completion.java @@ -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 { diff --git a/mug/src/main/java/com/google/mu/util/concurrent/Fanout.java b/mug/src/main/java/com/google/mu/util/concurrent/Fanout.java index 37467ade0..d04491da3 100644 --- a/mug/src/main/java/com/google/mu/util/concurrent/Fanout.java +++ b/mug/src/main/java/com/google/mu/util/concurrent/Fanout.java @@ -481,8 +481,8 @@ 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); } @@ -490,8 +490,8 @@ void run() throws StructuredConcurrencyInterruptedException { @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)); } } } diff --git a/mug/src/test/java/com/google/mu/util/concurrent/CompletionTest.java b/mug/src/test/java/com/google/mu/util/concurrent/CompletionTest.java index e3d7ccab1..5687005a0 100644 --- a/mug/src/test/java/com/google/mu/util/concurrent/CompletionTest.java +++ b/mug/src/test/java/com/google/mu/util/concurrent/CompletionTest.java @@ -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(); } @@ -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(() -> {