< prev index next >

src/jdk.jdi/share/classes/com/sun/tools/jdi/VMState.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 24,37 **** */ package com.sun.tools.jdi; import java.lang.ref.WeakReference; ! import java.util.ArrayList; ! import java.util.Arrays; ! import java.util.Iterator; ! import java.util.List; import com.sun.jdi.ThreadGroupReference; import com.sun.jdi.ThreadReference; import com.sun.jdi.VirtualMachine; --- 24,34 ---- */ package com.sun.tools.jdi; import java.lang.ref.WeakReference; ! import java.util.*; import com.sun.jdi.ThreadGroupReference; import com.sun.jdi.ThreadReference; import com.sun.jdi.VirtualMachine;
*** 42,57 **** private final List<WeakReference<VMListener>> listeners = new ArrayList<>(); // synchronized (this) private boolean notifyingListeners = false; // synchronized (this) /* * Certain information can be cached only when the entire VM is ! * suspended and there are no pending resumes. The fields below ! * are used to track whether there are pending resumes. (There ! * is an assumption that JDWP command ids are increasing over time.) */ ! private int lastCompletedCommandId = 0; // synchronized (this) ! private int lastResumeCommandId = 0; // synchronized (this) // This is cached only while the VM is suspended private static class Cache { List<ThreadGroupReference> groups = null; // cached Top Level ThreadGroups List<ThreadReference> threads = null; // cached Threads --- 39,52 ---- private final List<WeakReference<VMListener>> listeners = new ArrayList<>(); // synchronized (this) private boolean notifyingListeners = false; // synchronized (this) /* * Certain information can be cached only when the entire VM is ! * suspended and there are no pending resumes. The field below ! * is used to track whether there are pending resumes. */ ! private final Set<Integer> pendingResumeCommands = Collections.synchronizedSet(new HashSet<>()); // This is cached only while the VM is suspended private static class Cache { List<ThreadGroupReference> groups = null; // cached Top Level ThreadGroups List<ThreadReference> threads = null; // cached Threads
*** 95,110 **** /* * A JDWP command has been completed (reply has been received). * Update data that tracks pending resume commands. */ ! synchronized void notifyCommandComplete(int id) { ! lastCompletedCommandId = id; } synchronized void freeze() { ! if (cache == null && (lastCompletedCommandId >= lastResumeCommandId)) { /* * No pending resumes to worry about. The VM is suspended * and additional state can be cached. Notify all * interested listeners. */ --- 90,105 ---- /* * A JDWP command has been completed (reply has been received). * Update data that tracks pending resume commands. */ ! void notifyCommandComplete(int id) { ! pendingResumeCommands.remove(id); } synchronized void freeze() { ! if (cache == null && (pendingResumeCommands.isEmpty())) { /* * No pending resumes to worry about. The VM is suspended * and additional state can be cached. Notify all * interested listeners. */
*** 113,123 **** } } synchronized PacketStream thawCommand(CommandSender sender) { PacketStream stream = sender.send(); ! lastResumeCommandId = stream.id(); thaw(); return stream; } /** --- 108,118 ---- } } synchronized PacketStream thawCommand(CommandSender sender) { PacketStream stream = sender.send(); ! pendingResumeCommands.add(stream.id()); thaw(); return stream; } /**
< prev index next >