tmf: Synchronize initialization methods of static fields
authorFrance Lapointe Nguyen <francelap@gmail.com>
Thu, 7 May 2015 21:00:11 +0000 (17:00 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 8 May 2015 03:17:40 +0000 (23:17 -0400)
Change-Id: Iedc625fb00e3f9745c03f3bea233c12bc5b9ca26
Signed-off-by: France Lapointe Nguyen <francelap@gmail.com>
Reviewed-on: https://git.eclipse.org/r/47355
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/TmfCoreTracer.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampFormat.java

index 49f573740302e4b4dc90741fb9a737e582353015..3baa68a416481f70e15917bd10149f5c9f7c70a5 100644 (file)
@@ -43,7 +43,7 @@ import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
  * @author Francois Chouinard
  */
 @SuppressWarnings("nls")
-public class TmfCoreTracer {
+public final class TmfCoreTracer {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -65,15 +65,25 @@ public class TmfCoreTracer {
     // ------------------------------------------------------------------------
 
     // Classes tracing flags
-    private static boolean fComponentClassEnabled = false;
-    private static boolean fRequestClassEnabled   = false;
-    private static boolean fSignalClassEnabled    = false;
-    private static boolean fEventClassEnabled     = false;
-    private static boolean fAnalysisClassEnabled  = false;
+    private static volatile boolean fComponentClassEnabled = false;
+    private static volatile boolean fRequestClassEnabled   = false;
+    private static volatile boolean fSignalClassEnabled    = false;
+    private static volatile boolean fEventClassEnabled     = false;
+    private static volatile boolean fAnalysisClassEnabled  = false;
 
     // Trace log file
     private static BufferedWriter fTraceFile;
 
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+    /**
+     * Constructor
+     */
+    private TmfCoreTracer() {
+        // Do nothing
+    }
+
     // ------------------------------------------------------------------------
     // Start/stop tracing - controlled by the plug-in
     // ------------------------------------------------------------------------
@@ -81,7 +91,7 @@ public class TmfCoreTracer {
     /**
      * Set the tracing flags according to the launch configuration
      */
-    public static void init() {
+    public static synchronized void init() {
 
         String traceKey;
         boolean isTracing = false;
@@ -130,7 +140,7 @@ public class TmfCoreTracer {
     /**
      * Close the trace log file
      */
-    public static void stop() {
+    public static synchronized void stop() {
         if (fTraceFile != null) {
             try {
                 fTraceFile.close();
index 0cdbba1ab416229e7764f6971db2baf8ae72f136..8ec5f4efb2541a5e52fa5beaeb621a4312db55c0 100644 (file)
@@ -300,7 +300,7 @@ public class TmfTimestampFormat extends SimpleDateFormat {
     /**
      * Update the default time and default interval formats
      */
-    public static void updateDefaultFormats() {
+    public static synchronized void updateDefaultFormats() {
         fDefaultTimeFormat = new TmfTimestampFormat(
                 TmfTimePreferences.getTimePattern(),
                 TmfTimePreferences.getTimeZone(),
@@ -311,7 +311,7 @@ public class TmfTimestampFormat extends SimpleDateFormat {
     /**
      * @return the default time format pattern
      */
-    public static TmfTimestampFormat getDefaulTimeFormat() {
+    public static synchronized TmfTimestampFormat getDefaulTimeFormat() {
         if (fDefaultTimeFormat == null) {
             fDefaultTimeFormat = new TmfTimestampFormat(
                     TmfTimePreferences.getTimePattern(),
@@ -324,7 +324,7 @@ public class TmfTimestampFormat extends SimpleDateFormat {
     /**
      * @return the default interval format pattern
      */
-    public static TmfTimestampFormat getDefaulIntervalFormat() {
+    public static synchronized TmfTimestampFormat getDefaulIntervalFormat() {
         if (fDefaultIntervalFormat == null) {
             fDefaultIntervalFormat = new TmfTimestampFormat(TmfTimePreferences.getIntervalPattern());
         }
This page took 0.052211 seconds and 5 git commands to generate.