Sometimes, Mutiny needs to execute tasks on other threads, such as monitoring time or delaying actions.
Most operators relying on such capacity let you pass either a
ScheduledExecutorService or an
By default, Mutiny uses the a cached thread pool as default executor, that creates new threads as needed, but reuse previously constructed threads when they are available.
ScheduledExecutorService is also created but delegates the execution of the delayed/scheduled tasks to the default executor.
In the case you want to integrate Mutiny with a thread pool managed by a platform, you can configure it using
Uni<Integer> uni1 = Uni.createFrom().item(1) .emitOn(Infrastructure.getDefaultExecutor()); Uni<Integer> uni2 = Uni.createFrom().item(2) .onItem().delayIt() .onExecutor(Infrastructure.getDefaultWorkerPool()) .by(Duration.ofMillis(10));
You can configure the default executor using the
|If you are using Quarkus, the default executor is already configured to use the Quarkus worker thread pool.|