From 89451874c383eec4776935b87488514e42abbca8 Mon Sep 17 00:00:00 2001 From: Vaci Koblizek Date: Wed, 14 Oct 2020 15:54:21 +0100 Subject: [PATCH] simplify server runOnce --- runtime/src/main/java/org/capnproto/TwoPartyClient.java | 2 +- runtime/src/main/java/org/capnproto/TwoPartyServer.java | 2 +- runtime/src/test/java/org/capnproto/TwoPartyTest.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/src/main/java/org/capnproto/TwoPartyClient.java b/runtime/src/main/java/org/capnproto/TwoPartyClient.java index 474dd86..ee3a89c 100644 --- a/runtime/src/main/java/org/capnproto/TwoPartyClient.java +++ b/runtime/src/main/java/org/capnproto/TwoPartyClient.java @@ -32,7 +32,7 @@ public class TwoPartyClient { return rpcSystem.bootstrap(vatId.asReader()); } - public synchronized CompletableFuture runOnce() { + public CompletableFuture runOnce() { return this.rpcSystem.runOnce(); } } diff --git a/runtime/src/main/java/org/capnproto/TwoPartyServer.java b/runtime/src/main/java/org/capnproto/TwoPartyServer.java index 8a27315..f34d261 100644 --- a/runtime/src/main/java/org/capnproto/TwoPartyServer.java +++ b/runtime/src/main/java/org/capnproto/TwoPartyServer.java @@ -55,7 +55,7 @@ public class TwoPartyServer { } public synchronized CompletableFuture runOnce() { - var done = new CompletableFuture(); + var done = new CompletableFuture<>(); for (var conn: connections) { done = CompletableFuture.anyOf(done, conn.runOnce()); } diff --git a/runtime/src/test/java/org/capnproto/TwoPartyTest.java b/runtime/src/test/java/org/capnproto/TwoPartyTest.java index 0e0e4d5..7ffe216 100644 --- a/runtime/src/test/java/org/capnproto/TwoPartyTest.java +++ b/runtime/src/test/java/org/capnproto/TwoPartyTest.java @@ -83,7 +83,7 @@ public class TwoPartyTest { params.setParam0(4321); var response = request.send(); while (!response.isDone()) { - CompletableFuture.anyOf(response, server.runOnce()).join(); + CompletableFuture.anyOf(response, this.client.runOnce(), server.runOnce()).join(); } Assert.assertTrue(response.isDone()); var results = response.get(); @@ -101,7 +101,7 @@ public class TwoPartyTest { var params = request.getParams(); var response = request.send(); while (!response.isDone()) { - CompletableFuture.anyOf(response, server.runOnce()).join(); + CompletableFuture.anyOf(response, this.client.runOnce(), server.runOnce()).join(); } Assert.assertTrue(response.isDone());