@Test public void testExecute() throws InterruptedException { int limit = 10; BlockingEventloopExecutor eventloopExecutor = BlockingEventloopExecutor.create(eventloop, limit); eventloop.keepAlive(true); Thread eventloopThread = new Thread(eventloop); eventloopThread.start(); List<Integer> actual = new ArrayList<>(); List<Integer> expected = new ArrayList<>(); for (int i = 0; i < 20; i++) { int finalI = i; expected.add(i); eventloopExecutor.execute(() -> actual.add(finalI)); } eventloopExecutor.execute(() -> eventloop.keepAlive(false)); eventloopThread.join(); assertEquals(actual, expected); }
@Override public void execute(@NotNull Runnable runnable) { try { post(() -> { try { runnable.run(); } finally { complete(); } }); } catch (InterruptedException ignored) { } }
BlockingEventloopExecutor implements EventloopExecutor { @Override public void execute(@NotNull Runnable runnable) { try { post(() -> { try { runnable.run(); } finally { complete(); } }); } catch (InterruptedException ignored) { } } }
BlockingEventloopExecutor implements EventloopExecutor { @Override public void execute(@NotNull Runnable runnable) { try { post(() -> { try { runnable.run(); } finally { complete(); } }); } catch (InterruptedException ignored) { } } private  BlockingEventloopExecutor(Eventloop eventloop, int limit); }
BlockingEventloopExecutor implements EventloopExecutor { @Override public void execute(@NotNull Runnable runnable) { try { post(() -> { try { runnable.run(); } finally { complete(); } }); } catch (InterruptedException ignored) { } } private  BlockingEventloopExecutor(Eventloop eventloop, int limit); static BlockingEventloopExecutor create(Eventloop eventloop, int limit); int getLimit(); @Override void execute(@NotNull Runnable runnable); @NotNull @Override CompletableFuture<Void> submit(@NotNull Runnable computation); @NotNull @Override CompletableFuture<T> submit(Supplier<? extends AsyncComputation<T>> computation); }
BlockingEventloopExecutor implements EventloopExecutor { @Override public void execute(@NotNull Runnable runnable) { try { post(() -> { try { runnable.run(); } finally { complete(); } }); } catch (InterruptedException ignored) { } } private  BlockingEventloopExecutor(Eventloop eventloop, int limit); static BlockingEventloopExecutor create(Eventloop eventloop, int limit); int getLimit(); @Override void execute(@NotNull Runnable runnable); @NotNull @Override CompletableFuture<Void> submit(@NotNull Runnable computation); @NotNull @Override CompletableFuture<T> submit(Supplier<? extends AsyncComputation<T>> computation);  }