ec6def1663693317323acab717bc97f07c38cecb
[phpeclipse.git] /
1 package net.sourceforge.phpeclipse.xdebug.core.xdebug;
2
3 import java.util.HashMap;
4 //import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
5 import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
6
7 public class ResponseList {
8         int fLastId;
9         HashMap fList;
10
11         public ResponseList() {
12                 fLastId = -1;
13                 fList = new HashMap();
14         }
15
16         public synchronized void add(XDebugResponse response, int id) {
17                 fList.put(new Integer(id), response);
18                 fLastId = id;
19                 notifyAll();
20         }
21
22         public synchronized XDebugResponse get(int id) {
23                 while (id > fLastId) {
24                         try {
25                                 wait();
26                         } catch (InterruptedException e) {
27                                 e.printStackTrace();
28                         }
29                 }
30                 if (fList.containsKey(new Integer(id)))
31                         return (XDebugResponse) fList.remove(new Integer(id));
32                 else
33                         return null;
34         }
35 }