/*
* 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.
*/
/*
* protected through the 'this' monitor.
*/
boolean closed = false;
super(vm);
target.addEventQueue(this);
}
/*
* Override superclass back to default equality
*/
return this == obj;
}
public int hashCode() {
return System.identityHashCode(this);
}
notifyAll();
}
synchronized int size() {
}
synchronized void close() {
if (!closed) {
closed = true; // OK for this the be first since synchronized
// place VMDisconnectEvent into queue
}
}
return remove(0);
}
/**
* Filter out events not for user's eyes.
* Then filter out empty sets.
*/
if (timeout < 0) {
throw new IllegalArgumentException("Timeout cannot be negative");
}
while (true) {
if (fullEventSet == null) {
break;
}
/*
* Remove events from the event set for which
* there is no corresponding enabled request (
* this includes our internally requested events.)
* This never returns null
*/
break;
}
}
vm.notifySuspend();
}
return eventSet;
}
do {
// Waiting forever, so removeUnfiltered() is never null
/*
* Currently, no internal events are requested with a suspend
* policy other than none, so we don't check for notifySuspend()
* here. If this changes in the future, there is much
* infrastructure that needs to be updated.
*/
return eventSet;
}
return thread;
}
}
throws InterruptedException {
/*
* Make sure the VM has completed initialization before
* trying to build events.
*/
synchronized(this) {
/*
* If there's already something there, no need
* for anything elaborate.
*/
} else {
/*
* If a timeout was specified, create a thread to
* notify this one when a timeout
* occurs. We can't use the timed version of wait()
* because it is possible for multiple enqueue() calls
* before we see something in the eventSet queue
* (this is possible when multiple threads call
* remove() concurrently -- not a great idea, but
* it should be supported). Even if enqueue() did a
* notify() instead of notifyAll() we are not able to
* use a timed wait because there's no way to distinguish
* a timeout from a notify. That limitation implies a
* possible race condition between a timed out thread
* and a notified thread.
*/
try {
if (timeout > 0) {
}
while (shouldWait(timerThread)) {
this.wait();
}
} finally {
}
}
if (closed) {
throw new VMDisconnectedException();
}
} else {
}
}
}
// The build is synchronized on the event set, don't hold
// the queue lock.
}
return eventSet;
}
private boolean timedOut = false;
private long timeout;
}
boolean timedOut() {
return timedOut;
}
public void run() {
try {
synchronized(queue) {
timedOut = true;
}
} catch (InterruptedException e) {
// Exit without notifying
}
}
}
}