job: overseer can be looked up and re-used
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 18 Jun 2015 05:07:54 +0000 (14:07 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 18 Jun 2015 05:09:55 +0000 (14:09 +0900)
Change-Id: Iafbbfbffc1817695b2e71e0898011ffa8e431ece
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
src/org/tizen/emulator/manager/EmulatorManager.java
src/org/tizen/emulator/manager/job/Overseer.java

index 41b4488..e74317b 100755 (executable)
@@ -310,12 +310,18 @@ public class EmulatorManager {
                        exitEmulatorManager(1);
                }
 
-               Overseer startupOverseer = Overseer.newOverseer("Start-up", InitAboutContents.class,
+               Overseer startupPreparations = Overseer.newOverseer("StartupPreparations",
+                               InitAboutContents.class);
+               startupPreparations.startWork();
+
+               Overseer checkers = Overseer.newOverseer("Checkers",
                                CheckVT.class, CheckGPU.class, CheckSDCard.class);
-               startupOverseer.startWork();
+               checkers.startWork();
+
                // FIXME: we should not join overseer thread.
                // but now we are not ready for asynchronous actions.
-               startupOverseer.join();
+               startupPreparations.join();
+               checkers.join();
 
                if (isConsoleMode) {
                        EmulatorManager.startConsoleProcessor();
index 147d1ea..41ec93a 100644 (file)
@@ -37,6 +37,8 @@ import java.util.logging.Level;
 import org.tizen.emulator.manager.logging.EMLogger;
 
 public class Overseer {
+       private static final List<Overseer> overseers = new ArrayList<Overseer>();
+
        private final List<Class<? extends Job>> jobClasses = new ArrayList<Class<? extends Job>>();
        private Thread overseerThread;
        private CountDownLatch doneSignal;
@@ -44,6 +46,16 @@ public class Overseer {
 
        private Overseer() {};
 
+       public static Overseer lookupOverseer(String name) {
+               for (Overseer overseer: overseers) {
+                       if (overseer.name.equals(name)) {
+                               return overseer;
+                       }
+               }
+
+               return null;
+       }
+
        protected void startWorkInternal() throws InterruptedException {
                doneSignal = new CountDownLatch(jobClasses.size());
 
@@ -67,6 +79,8 @@ public class Overseer {
                        overseer.registerJob(jobCls);
                }
 
+               overseers.add(overseer);
+
                return overseer;
        }