public void invoke(IManagerCommand command) { if (isManagerThread()) { myThread.processCommand(command); } else { schedule(command); } }
public void invokeAndWait(final IManagerCommand command) { if (isManagerThread()) { myThread.processCommand(command); } else { final CountDownLatch countDown = new CountDownLatch(1); schedule( Commands.fromClosure( new _FunctionTypes._void_P0_E0() { public void invoke() { try { command.invoke(); } finally { countDown.countDown(); } } }, new _FunctionTypes._void_P0_E0() { public void invoke() { try { command.cancel(); } finally { countDown.countDown(); } } })); try { countDown.await(); } catch (InterruptedException ignore) { } } }
public ManagerThread() { myThread.start(); }