frankgh commented on code in PR #72:
URL: https://github.com/apache/cassandra-sidecar/pull/72#discussion_r1367520631


##########
src/main/java/org/apache/cassandra/sidecar/concurrent/ExecutorPools.java:
##########
@@ -119,9 +120,45 @@ public long setPeriodic(long delay, Handler<Long> handler)
         public long setPeriodic(long delay, Handler<Long> handler, boolean 
ordered)
         {
             return vertx.setPeriodic(delay,
-                                     id -> 
workerExecutor.executeBlocking(promise -> {
+                                     id -> workerExecutor.executeBlocking(() 
-> {
                                          handler.handle(id);
-                                         promise.complete();
+                                         return id;
+                                     }, ordered));
+        }
+
+        /**
+         * Set a periodic timer to fire every {@code delay} milliseconds with 
initial delay, at which point
+         * {@code handler} will be called with the id of the timer.
+         *
+         * @param initialDelay the initial delay in milliseconds
+         * @param delay        the delay in milliseconds, after which the 
timer will fire
+         * @param handler      the handler that will be called with the timer 
ID when the timer fires
+         * @return the unique ID of the timer
+         */
+        public long setPeriodic(long initialDelay, long delay, Handler<Long> 
handler)
+        {
+            return setPeriodic(initialDelay, delay, handler, false);
+        }
+
+        /**
+         * Set a periodic timer to fire every {@code delay} milliseconds with 
initial delay, at which point
+         * {@code handler} will be called with the id of the timer.
+         *
+         * @param initialDelay the initial delay in milliseconds
+         * @param delay        the delay in milliseconds, after which the 
timer will fire
+         * @param handler      the handler that will be called with the timer 
ID when the timer fires
+         * @param ordered      if true then executeBlocking is called several 
times on the same context, the
+         *                     executions for that context will be executed 
serially, not in parallel. if false
+         *                     then they will be no ordering guarantees
+         * @return the unique ID of the timer
+         */
+        public long setPeriodic(long initialDelay, long delay, Handler<Long> 
handler, boolean ordered)
+        {
+            return vertx.setPeriodic(initialDelay,
+                                     delay,
+                                     id -> workerExecutor.executeBlocking(() 
-> {
+                                         handler.handle(id);
+                                         return id;

Review Comment:
   ok, I think it's a valid concern. I will double check, but it looks like the 
exception now should be `RejectedExecutionException`. I assume the intention 
was to maintain the pool API expectations instead of throwing an 
`IllegalStateException` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to