]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/logger/ThreadLogger.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / logger / ThreadLogger.java
index 99ac51fecc15ef552e70126a7a64cd616f4ae016..d569d4aad2a3c4b4c70fd7d95a3d0be9963c7b85 100644 (file)
@@ -1,91 +1,91 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.utils.threads.logger;\r
-\r
-import java.io.DataOutput;\r
-import java.io.DataOutputStream;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-\r
-public class ThreadLogger implements IThreadLogger {\r
-\r
-    public static String LOG_FILE = "d:\\threads.log";\r
-    \r
-    public static boolean LOG = false;\r
-\r
-    static Object loggerCreationLock = new Object();\r
-    static ThreadLogger logger = null; \r
-\r
-    DataOutput log;\r
-\r
-    public ThreadLogger() {\r
-        if(LOG) {\r
-            try {\r
-                FileOutputStream stream = new FileOutputStream(LOG_FILE);\r
-                log = new DataOutputStream(stream);\r
-            } catch (FileNotFoundException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-\r
-    public static ThreadLogger getInstance() {\r
-        if(logger == null) {\r
-            synchronized (loggerCreationLock) {\r
-                if(logger == null)\r
-                    logger = new ThreadLogger();       \r
-            }                   \r
-        }\r
-        return logger;\r
-    }\r
-\r
-    public class Task implements ITask {\r
-\r
-        String name;\r
-        long beginTime;\r
-        long endTime;\r
-        long threadId;\r
-\r
-        public Task(String name) {                     \r
-            this.name = name;\r
-            this.threadId = Thread.currentThread().getId();\r
-            this.beginTime = System.nanoTime();\r
-        }\r
-\r
-        @Override\r
-        public void finish() {\r
-            this.endTime = System.nanoTime();\r
-            if(LOG && log != null) {\r
-                \r
-                try {\r
-                    synchronized(log) {\r
-                        log.writeUTF(name);\r
-                        log.writeLong(threadId);\r
-                        log.writeLong(beginTime);\r
-                        log.writeLong(endTime);\r
-                    }\r
-                } catch(IOException e) {\r
-                    e.printStackTrace();\r
-                }\r
-\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    @Override\r
-    public ITask begin(String taskName) {\r
-        return new Task(taskName);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.utils.threads.logger;
+
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class ThreadLogger implements IThreadLogger {
+
+    public static String LOG_FILE = "d:\\threads.log";
+    
+    public static boolean LOG = false;
+
+    static Object loggerCreationLock = new Object();
+    static ThreadLogger logger = null; 
+
+    DataOutput log;
+
+    public ThreadLogger() {
+        if(LOG) {
+            try {
+                FileOutputStream stream = new FileOutputStream(LOG_FILE);
+                log = new DataOutputStream(stream);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static ThreadLogger getInstance() {
+        if(logger == null) {
+            synchronized (loggerCreationLock) {
+                if(logger == null)
+                    logger = new ThreadLogger();       
+            }                   
+        }
+        return logger;
+    }
+
+    public class Task implements ITask {
+
+        String name;
+        long beginTime;
+        long endTime;
+        long threadId;
+
+        public Task(String name) {                     
+            this.name = name;
+            this.threadId = Thread.currentThread().getId();
+            this.beginTime = System.nanoTime();
+        }
+
+        @Override
+        public void finish() {
+            this.endTime = System.nanoTime();
+            if(LOG && log != null) {
+                
+                try {
+                    synchronized(log) {
+                        log.writeUTF(name);
+                        log.writeLong(threadId);
+                        log.writeLong(beginTime);
+                        log.writeLong(endTime);
+                    }
+                } catch(IOException e) {
+                    e.printStackTrace();
+                }
+
+            }
+        }
+
+    }
+
+    @Override
+    public ITask begin(String taskName) {
+        return new Task(taskName);
+    }
+
+}