View Javadoc
1   /*
2    * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4    *
5    * This code is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License version 2 only, as
7    * published by the Free Software Foundation.  Oracle designates this
8    * particular file as subject to the "Classpath" exception as provided
9    * by Oracle in the LICENSE file that accompanied this code.
10   *
11   * This code is distributed in the hope that it will be useful, but WITHOUT
12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   * version 2 for more details (a copy is included in the LICENSE file that
15   * accompanied this code).
16   *
17   * You should have received a copy of the GNU General Public License version
18   * 2 along with this work; if not, write to the Free Software Foundation,
19   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20   *
21   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22   * or visit www.oracle.com if you need additional information or have any
23   * questions.
24   */
25  
26  package com.sun.jdi.event;
27  
28  import com.sun.jdi.*;
29  
30  /**
31   * Manager of incoming debugger events for a target VM.
32   * Events are always grouped in {@link EventSet}s.
33   * EventSets generated by the debugger back end can be read
34   * here. There is one instance of EventQueue assigned to a particular
35   * {@link com.sun.jdi.VirtualMachine VirtualMachine}.
36   * <P>
37   * Some events cause the suspension of the target VM - event requests
38   * ({@link com.sun.jdi.request}) with a
39   * {@link com.sun.jdi.request.EventRequest#suspendPolicy() suspend policy}
40   * of {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL SUSPEND_ALL}
41   * or {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD
42   * SUSPEND_EVENT_THREAD} and sometimes
43   * {@link VMStartEvent}.
44   * If these suspensions are not resumed the target VM will hang.
45   * Thus, it is always good policy to
46   * {@link #remove() remove()} every EventSet from the
47   * event queue until an EventSet containing a
48   * {@link VMDisconnectEvent} is read.
49   * Unless {@link com.sun.jdi.VirtualMachine#resume() resume} is
50   * being handled in another way, each EventSet should invoke
51   * {@link EventSet#resume()}.
52   *
53   * @see EventSet
54   * @see VirtualMachine
55   *
56   * @author Robert Field
57   * @since  1.3
58   */
59  
60  @jdk.Exported
61  public interface EventQueue extends Mirror {
62  
63      /**
64       * Waits forever for the next available event.
65       *
66       * @return the next {@link EventSet}.
67       * @throws InterruptedException if any thread has interrupted
68       * this thread.
69       * @throws com.sun.jdi.VMDisconnectedException if the connection
70       * to the target VM is no longer available.  Note this will always
71       * be preceded by a {@link com.sun.jdi.event.VMDisconnectEvent}.
72       */
73      EventSet remove() throws InterruptedException;
74  
75      /**
76       * Waits a specified time for the next available event.
77       *
78       * @param timeout Time in milliseconds to wait for the next event
79       * @return the next {@link EventSet}, or null if there is a timeout.
80       * @throws InterruptedException if any thread has interrupted
81       * this thread.
82       * @throws com.sun.jdi.VMDisconnectedException if the connection
83       * to the target VM is no longer available.  Note this will always
84       * be preceded by a {@link com.sun.jdi.event.VMDisconnectEvent}.
85       * @throws IllegalArgumentException if the timeout argument
86       * contains an illegal value.
87       */
88      EventSet remove(long timeout) throws InterruptedException;
89  }