@Test void testChunkyWithCustomExecutor() { ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); PeriodicalChannel pc = createChannelWithNoAvailableData(25, 3); Multi<ByteBuffer> publisher = IoMulti.multiFromByteChannelBuilder(pc) .retrySchema(RetrySchema.constant(2)) .executor(executorService) .build(); byte[] bytes = Multi.create(publisher) .collect(new BufferCollector()) .await(5, TimeUnit.SECONDS); assertThat(bytes.length, is(TEST_DATA_SIZE)); assertByteSequence(bytes); assertThat(pc.threads.size(), is(2)); assertThat(pc.isOpen(), is(false)); MultiFromByteChannel multi = (MultiFromByteChannel) publisher; LazyValue<ScheduledExecutorService> executor = multi.executor(); assertThat("Executor was provided", executor.isLoaded(), is(true)); ScheduledExecutorService usedExecutor = executor.get(); assertThat("Executor should not have been shut down, as we use an explicit one", usedExecutor.isShutdown(), is(false)); assertThat("Executor should have been our instance", usedExecutor, is(sameInstance(executorService))); executorService.shutdownNow(); }
LazyValue<ScheduledExecutorService> executor() { return executor; }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } MultiFromByteChannel(IoMulti.MultiFromByteChannelBuilder builder); }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } MultiFromByteChannel(IoMulti.MultiFromByteChannelBuilder builder); @Override void subscribe(Flow.Subscriber<? super ByteBuffer> subscriberParam); }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } MultiFromByteChannel(IoMulti.MultiFromByteChannelBuilder builder); @Override void subscribe(Flow.Subscriber<? super ByteBuffer> subscriberParam);  }