src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java

Print this page

        

*** 23,57 **** * questions. */ package sun.lwawt.macosx; import sun.awt.datatransfer.ToolkitThreadBlockedHandler; ! final class CToolkitThreadBlockedHandler implements ToolkitThreadBlockedHandler { ! private final LWCToolkit toolkit = ! java.awt.Toolkit.getDefaultToolkit() instanceof LWCToolkit ! ? (LWCToolkit)java.awt.Toolkit.getDefaultToolkit() ! : null; ! ! public void lock() { ! } ! ! public void unlock() { ! } ! ! protected boolean isOwned() { ! return false; } public void enter() { ! // Despite the naming of this method, on MacOS only one ! // event is read and dispatched before this method returns. ! // This call is non-blocking and does not wait for an event ! if (toolkit != null) { ! toolkit.startNativeNestedEventLoop(); } } public void exit() { } } --- 23,57 ---- * questions. */ package sun.lwawt.macosx; + import sun.awt.Mutex; import sun.awt.datatransfer.ToolkitThreadBlockedHandler; ! final class CToolkitThreadBlockedHandler extends Mutex implements ToolkitThreadBlockedHandler { ! private long awtRunLoopMediator = 0; ! private final boolean processEvents; ! ! CToolkitThreadBlockedHandler() { ! super(); ! this.processEvents = true; } public void enter() { ! if (!isOwned()) { ! throw new IllegalMonitorStateException(); } + awtRunLoopMediator = LWCToolkit.createAWTRunLoopMediator(); + unlock(); + LWCToolkit.doAWTRunLoop(awtRunLoopMediator, processEvents); + lock(); } public void exit() { + if (!isOwned()) { + throw new IllegalMonitorStateException(); + } + LWCToolkit.stopAWTRunLoop(awtRunLoopMediator); + awtRunLoopMediator = 0; } }