Is it a bad idea to initialize a periodic timer within a worker verticle?
I have the following concerns about this idea:1. Assuming that the periodic timer gets cancelled after 10 minutes, doe the worker thread get completely blocked for 10 minutes?
2. Assuming that I have 4 worker threads on my machine, does it mean that I can have most 4 (uncancelled) timers while more timers would lead to blocking exceptions?
3. Is the concept of vertx timers only designed for the eventloop and should be avoided to be used within the worker context?
How to use timers to invoke blocking code?4. Is it a better idea to setup the periodic timer within the eventloop and use executeBlocking inside the handler implementation to run invoke the blocking code?
5. Is vertx able to cancel a timer by the timer-ID passed as an argument to the handler from inside a executeBlocking code although the timer runs in the eventloop?
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/4afdc7e4-5bcc-4691-bc1d-30667ba08d0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
class TimerTest extends AbstractVerticle{
@Override
public void start() throws Exception {
//****************************
//Original context (eventloop)
//****************************
vertx.setPeriodic(10000, timerId -> {
vertx.executeBlocking(future -> {
//********************************
//Worker thread but which context?
//********************************
//Invoke some blocking: myBlockingCode();
vertx.cancelTimer(timerId); //<-- does this work even within the the worker thread?
}, false, res -> {...});
});
}
}--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/293fac59-28d2-4a57-982c-c64f543aa86d%40googlegroups.com.