1 11 package org.eclipse.jdi.internal.event; 12 13 14 import java.io.IOException ; 15 16 import org.eclipse.jdi.TimeoutException; 17 import org.eclipse.jdi.internal.MirrorImpl; 18 import org.eclipse.jdi.internal.VirtualMachineImpl; 19 import org.eclipse.jdi.internal.connect.PacketReceiveManager; 20 import org.eclipse.jdi.internal.jdwp.JdwpCommandPacket; 21 import org.eclipse.jdi.internal.request.RequestID; 22 23 import com.sun.jdi.VMDisconnectedException; 24 import com.sun.jdi.event.EventQueue; 25 import com.sun.jdi.event.EventSet; 26 27 33 public class EventQueueImpl extends MirrorImpl implements EventQueue { 34 35 private boolean genereatedVMDisconnectEvent = false; 36 37 40 public EventQueueImpl(VirtualMachineImpl vmImpl) { 41 super("EventQueue", vmImpl); } 43 44 47 public EventSet remove() throws InterruptedException { 48 return remove(PacketReceiveManager.TIMEOUT_INFINITE); 49 } 50 51 54 public EventSet remove(long timeout) throws InterruptedException { 55 try { 60 EventSetImpl set; 62 do { 63 JdwpCommandPacket packet = getCommandVM(JdwpCommandPacket.E_COMPOSITE, timeout); 64 initJdwpEventSet(packet); 65 set = EventSetImpl.read(this, packet.dataInStream()); 66 handledJdwpEventSet(); 67 } while (set.isEmpty()); 68 return set; 69 } catch (TimeoutException e) { 70 handledJdwpEventSet(); 72 return null; 73 } catch (IOException e) { 74 handledJdwpEventSet(); 76 defaultIOExceptionHandler(e); 77 return null; 78 } catch(VMDisconnectedException e) { 79 handledJdwpEventSet(); 81 if (!genereatedVMDisconnectEvent) { 82 genereatedVMDisconnectEvent = true; 83 return new EventSetImpl(virtualMachineImpl(), new VMDisconnectEventImpl(virtualMachineImpl(), RequestID.nullID)); 84 } 85 throw e; 86 } 87 } 88 } 89 | Popular Tags |