/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This utility class is used to suspend execution on a thread
* while still allowing {@code EventDispatchThread} to dispatch events.
* The API methods of the class are thread-safe.
*
* @author Anton Tarasov, Artem Ananiev
*
* @since 1.7
*/
private long interval;
// Use a shared daemon timer to serve all the WaitDispatchSupports
// When this WDS expires, we cancel the timer task leaving the
// shared timer up and running
private static synchronized void initializeTimer() {
}
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
*
* @since 1.7
*/
this(dispatchThread, null);
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
* @param extCondition A conditional object used to determine
* if the loop should be terminated
*
* @since 1.7
*/
{
if (dispatchThread == null) {
throw new IllegalArgumentException("The dispatchThread can not be null");
}
this.dispatchThread = dispatchThread;
this.extCondition = extCond;
this.condition = new Conditional() {
public boolean evaluate() {
}
boolean extEvaluate =
}
return false;
}
return true;
}
};
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
* <p>
* The {@link EventFilter} is set on the {@code dispatchThread}
* while waiting. The filter is removed on completion of the
* waiting process.
* <p>
*
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
* @param filter {@code EventFilter} to be set
* @param interval A time interval to wait for. Note that
* when the waiting process takes place on EDT
* there is no guarantee to stop it in the given time
*
* @since 1.7
*/
{
this(dispatchThread, extCondition);
if (interval < 0) {
throw new IllegalArgumentException("The interval value must be >= 0");
}
if (interval != 0) {
}
}
/**
* @inheritDoc
*/
public boolean enter() {
if (!keepBlockingEDT.compareAndSet(false, true)) {
return false;
}
public void run() {
} else {
}
}
};
// We have two mechanisms for blocking: if we're on the
// dispatch thread, start a new event pump; if we're
// on any other thread, call wait() on the treelock
if (currentThread == dispatchThread) {
if (interval != 0) {
public void run() {
if (keepBlockingEDT.compareAndSet(true, false)) {
wakeupEDT();
}
}
}, interval);
}
// Dispose SequencedEvent we are dispatching on the the current
// AppContext, to prevent us from hang - see 4531693 for details
}
// In case the exit() method is called before starting
// new event pump it will post the waking event to EDT.
// The event will be handled after the the new event pump
// starts. Thus, the enter() method will not hang.
//
// Event pump should be privileged. See 6300270.
return null;
}
});
} else {
synchronized (getTreeLock()) {
}
try {
keepBlockingCT.set(true);
if (interval > 0) {
while (keepBlockingCT.get() &&
{
}
} else {
while (keepBlockingCT.get() &&
{
getTreeLock().wait();
}
}
} catch (InterruptedException e) {
} finally {
}
}
// If the waiting process has been stopped because of the
// time interval passed or an exception occurred, the state
// should be changed
keepBlockingEDT.set(false);
keepBlockingCT.set(false);
}
}
return true;
}
/**
* @inheritDoc
*/
public boolean exit() {
if (keepBlockingEDT.compareAndSet(true, false)) {
wakeupEDT();
return true;
}
return false;
}
}
public void run() {
synchronized (getTreeLock()) {
keepBlockingCT.set(false);
getTreeLock().notifyAll();
}
}
};
private void wakeupEDT() {
}
}