af980d40a211055d1dda66cc61325257cddac066
[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
6 public class ResponseList {
7         int fLastId;
8         HashMap fList;
9
10         public ResponseList() {
11                 fLastId = -1;
12                 fList = new HashMap();
13         }
14
15         public synchronized void add(DebugResponse response, int id) {
16                 fList.put(new Integer(id), response);
17                 fLastId = id;
18                 notifyAll();
19         }
20
21         public synchronized DebugResponse get(int id) {
22                 while (id > fLastId) {
23                         try {
24                                 wait();
25                         } catch (InterruptedException e) {
26                                 e.printStackTrace();
27                         }
28                 }
29                 if (fList.containsKey(new Integer(id)))
30                         return (DebugResponse) fList.remove(new Integer(id));
31                 else
32                         return null;
33         }
34 }