tmf: Correctly dispose sub-components of a partial history backend
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 10 Sep 2014 20:14:29 +0000 (16:14 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 15 Sep 2014 23:12:44 +0000 (19:12 -0400)
This will avoid lingering "event handler" threads when using partial
state histories.

Change-Id: I6044faa1c41a634e605161858b03ffb37b9e97ac
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/33221
Tested-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/partial/PartialStateSystem.java

index 6eed80aae04f4a9a5a243d4f6fe8ee4627c2b84c..f225edeb528b892a1ba64e326ac69671b59888de 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.CountDownLatch;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
 import org.eclipse.linuxtools.statesystem.core.backend.IStateHistoryBackend;
 import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException;
@@ -59,22 +60,22 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
      * A partial history needs the state input plugin to re-generate state
      * between checkpoints.
      */
-    private final ITmfStateProvider partialInput;
+    private final @NonNull ITmfStateProvider partialInput;
 
     /**
      * Fake state system that is used for partially rebuilding the states (when
      * going from a checkpoint to a target query timestamp).
      */
-    private final PartialStateSystem partialSS;
+    private final @NonNull PartialStateSystem partialSS;
 
     /** Reference to the "real" state history that is used for storage */
-    private final IStateHistoryBackend innerHistory;
+    private final @NonNull IStateHistoryBackend innerHistory;
 
     /** Checkpoints map, <Timestamp, Rank in the trace> */
-    private final TreeMap<Long, Long> checkpoints = new TreeMap<>();
+    private final @NonNull TreeMap<Long, Long> checkpoints = new TreeMap<>();
 
     /** Latch tracking if the initial checkpoint registration is done */
-    private final CountDownLatch checkpointsReady = new CountDownLatch(1);
+    private final @NonNull CountDownLatch checkpointsReady = new CountDownLatch(1);
 
     private final long granularity;
 
@@ -183,6 +184,8 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
 
     @Override
     public void dispose() {
+        partialInput.dispose();
+        partialSS.dispose();
         innerHistory.dispose();
     }
 
index 6dd273bc7d22bfcdd4b525621f41260de4000bd1..1a7ede3f9a3ee402d64898786c447789ba5f2379 100644 (file)
@@ -72,12 +72,20 @@ public class PartialStateSystem extends StateSystem {
         return realStateSystem;
     }
 
+    // ------------------------------------------------------------------------
+    // Publicized non-API methods
+    // ------------------------------------------------------------------------
+
     @Override
     public void replaceOngoingState(List<ITmfStateInterval> ongoingIntervals) {
-        /* We simply publicize StateSystem's method */
         super.replaceOngoingState(ongoingIntervals);
     }
 
+    @Override
+    public synchronized void dispose() {
+        super.dispose();
+    }
+
     // ------------------------------------------------------------------------
     // Methods regarding the query lock
     // ------------------------------------------------------------------------
This page took 0.026872 seconds and 5 git commands to generate.