| 1 | package com.renomad.minum.queue; | |
| 2 | ||
| 3 | import com.renomad.minum.state.Context; | |
| 4 | import com.renomad.minum.logging.ILogger; | |
| 5 | import com.renomad.minum.utils.TimeUtils; | |
| 6 | ||
| 7 | /** | |
| 8 |  * This class exists to properly kill off multiple action queues | |
| 9 |  */ | |
| 10 | public final class ActionQueueKiller { | |
| 11 | ||
| 12 |     private final Context context; | |
| 13 |     private final ILogger logger; | |
| 14 | ||
| 15 |     /** | |
| 16 |      * If we were interrupted while attempting to cleanly kill the | |
| 17 |      * action queues, this will be set true | |
| 18 |      */ | |
| 19 |     private boolean hadToInterrupt; | |
| 20 | ||
| 21 |     public ActionQueueKiller(Context context) { | |
| 22 |         this.context = context; | |
| 23 |         this.logger = context.getLogger(); | |
| 24 |         hadToInterrupt = false; | |
| 25 |     } | |
| 26 | ||
| 27 |     /** | |
| 28 |      * Systematically stops and kills all the action queues that have been | |
| 29 |      * instantiated in this call tree. | |
| 30 |      */ | |
| 31 |     public void killAllQueues() { | |
| 32 |         logger.logDebug(() -> TimeUtils.getTimestampIsoInstant() + " Killing all queue threads. "); | |
| 33 | 
1
1. killAllQueues : negated conditional → KILLED | 
        for (AbstractActionQueue aq = context.getActionQueueState().pollFromQueue(); aq != null ; aq = context.getActionQueueState().pollFromQueue()) { | 
| 34 |             AbstractActionQueue finalAq = aq; | |
| 35 | 
1
1. killAllQueues : removed call to com/renomad/minum/queue/AbstractActionQueue::stop → KILLED | 
            finalAq.stop(); | 
| 36 |             logger.logDebug(() -> TimeUtils.getTimestampIsoInstant() + " killing " + ((ActionQueue)finalAq).getQueueThread()); | |
| 37 | 
1
1. killAllQueues : negated conditional → KILLED | 
            if (((ActionQueue)finalAq).getQueueThread() != null) { | 
| 38 |                 hadToInterrupt = true; | |
| 39 |                 System.out.println("had to interrupt " + finalAq); | |
| 40 |                 ((ActionQueue)finalAq).getQueueThread().interrupt(); | |
| 41 |             } | |
| 42 |         } | |
| 43 |     } | |
| 44 | ||
| 45 |     /** | |
| 46 |      * A helpful indicator of whether this object was interrupted while | |
| 47 |      * looping through the list of action queues | |
| 48 |      * @return true If we were interrupted while attempting to cleanly kill the | |
| 49 |      *         action queues | |
| 50 |      */ | |
| 51 |     public boolean hadToInterrupt() { | |
| 52 | 
2
1. hadToInterrupt : replaced boolean return with false for com/renomad/minum/queue/ActionQueueKiller::hadToInterrupt → KILLED 2. hadToInterrupt : replaced boolean return with true for com/renomad/minum/queue/ActionQueueKiller::hadToInterrupt → KILLED  | 
        return hadToInterrupt; | 
| 53 |     } | |
| 54 | ||
| 55 | } | |
Mutations | ||
| 33 | 
 
 1.1  | 
|
| 35 | 
 
 1.1  | 
|
| 37 | 
 
 1.1  | 
|
| 52 | 
 
 1.1 2.2  |