]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/SerialExecutor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / ua / SerialExecutor.java
index fe705148f7d93728eddc13407498ee901ec2c5ac..7d52c59e9ca60d8a24136577b162963799345a8d 100644 (file)
@@ -1,55 +1,55 @@
-/*******************************************************************************\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
-\r
-package org.simantics.utils.threads.ua;\r
-\r
-import java.util.ArrayDeque;\r
-import java.util.Queue;\r
-import java.util.concurrent.Executor;\r
-\r
-/**\r
- * The executor serializes the submission of tasks to a second executor,\r
- * illustrating a composite executor.\r
- * \r
- * (This code is copied from the example in {@link Executor})\r
- */\r
-public class SerialExecutor implements Executor {\r
-    final Queue<Runnable> tasks = new ArrayDeque<Runnable>();\r
-    final Executor executor;\r
-    Runnable active;\r
-                \r
-    public SerialExecutor(Executor executor) {\r
-        this.executor = executor;\r
-    }\r
-                \r
-    public synchronized void execute(final Runnable r) {\r
-        tasks.offer(new Runnable() {\r
-            public void run() {\r
-                try {\r
-                    r.run();\r
-                } finally {\r
-                    scheduleNext();\r
-                }\r
-            }\r
-        });\r
-        if (active == null) {\r
-            scheduleNext();\r
-        }\r
-    }\r
-                \r
-    protected synchronized void scheduleNext() {\r
-        if ((active = tasks.poll()) != null) {\r
-            executor.execute(active);\r
-        }\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.ua;
+
+import java.util.ArrayDeque;
+import java.util.Queue;
+import java.util.concurrent.Executor;
+
+/**
+ * The executor serializes the submission of tasks to a second executor,
+ * illustrating a composite executor.
+ * 
+ * (This code is copied from the example in {@link Executor})
+ */
+public class SerialExecutor implements Executor {
+    final Queue<Runnable> tasks = new ArrayDeque<Runnable>();
+    final Executor executor;
+    Runnable active;
+                
+    public SerialExecutor(Executor executor) {
+        this.executor = executor;
+    }
+                
+    public synchronized void execute(final Runnable r) {
+        tasks.offer(new Runnable() {
+            public void run() {
+                try {
+                    r.run();
+                } finally {
+                    scheduleNext();
+                }
+            }
+        });
+        if (active == null) {
+            scheduleNext();
+        }
+    }
+                
+    protected synchronized void scheduleNext() {
+        if ((active = tasks.poll()) != null) {
+            executor.execute(active);
+        }
+    }
+       
+}