--- /dev/null
+/*******************************************************************************\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
+ *\r
+ * @author Toni Kalajainen\r
+ */\r
+package org.simantics.utils.threads;\r
+\r
+import java.util.concurrent.Executor;\r
+\r
+\r
+/**\r
+ * No thread switching\r
+ * \r
+ * @Todo Rename to InvokerWorks\r
+ */\r
+public class CurrentThread implements IThreadWorkQueue, Executor {\r
+\r
+ static CurrentThread INSTANCE = new CurrentThread();\r
+ \r
+ public static IThreadWorkQueue getThreadAccess()\r
+ {\r
+ return INSTANCE;\r
+ }\r
+ \r
+ CurrentThread() {}\r
+ \r
+ @Override\r
+ public Thread asyncExec(Runnable runnable) {\r
+ runnable.run();\r
+ return Thread.currentThread();\r
+ }\r
+\r
+ @Override\r
+ public boolean syncExec(Runnable runnable) {\r
+ runnable.run();\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public boolean currentThreadAccess() {\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public Thread getThread() {\r
+ return Thread.currentThread();\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return "Current thread";\r
+ }\r
+\r
+ @Override\r
+ public void execute(Runnable command) {\r
+ command.run();\r
+ }\r
+}\r