You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2020/03/23 14:41:24 UTC

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3041: Two JIRAs around Paging and AMQP

franz1981 commented on a change in pull request #3041: Two JIRAs around Paging and AMQP
URL: https://github.com/apache/activemq-artemis/pull/3041#discussion_r396490919
 
 

 ##########
 File path: artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ProcessorBase.java
 ##########
 @@ -99,45 +98,23 @@ public void shutdown(long timeout, TimeUnit unit) {
       }
    }
 
-   /**
-    * It will wait the current execution (if there is one) to finish
-    * but will not complete any further executions
-    */
+   /** It will shutdown the executor however it will not wait for finishing tasks*/
    public int shutdownNow(Consumer<? super T> onPendingItem) {
       //alert anyone that has been requested (at least) an immediate shutdown
       requestedForcedShutdown = true;
       requestedShutdown = true;
 
-      if (inHandler()) {
-         stateUpdater.set(this, STATE_FORCED_SHUTDOWN);
-      } else {
-         //it could take a very long time depending on the current executing task
-         do {
-            //alert the ExecutorTask (if is running) to just drain the current backlog of tasks
-            final int startState = stateUpdater.get(this);
-            if (startState == STATE_FORCED_SHUTDOWN) {
-               //another thread has completed a forced shutdown: let it to manage the tasks cleanup
-               break;
-            }
-            if (startState == STATE_RUNNING) {
-               //wait 100 ms to avoid burning CPU while waiting and
-               //give other threads a chance to make progress
-               LockSupport.parkNanos(100_000_000L);
-            }
-         }
-         while (!stateUpdater.compareAndSet(this, STATE_NOT_RUNNING, STATE_FORCED_SHUTDOWN));
-         //this could happen just one time: the forced shutdown state is the last one and
-         //can be set by just one caller.
-         //As noted on the execute method there is a small chance that some tasks would be enqueued
+      if (!inHandler()) {
+         flush(1, TimeUnit.SECONDS);
 
 Review comment:
   I would use some named const somewhere to help understand why is 1 second or I won't wait at all

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services