comparison rep/channel/SelectorSimulator.java @ 234:0498425202a4

made ChannelSimulator no extends SelectableChannelSimulator but REPSocketChannel directly
author kent
date Sun, 31 Aug 2008 19:02:34 +0900
parents 3e0cd34d625d
children cf9328e66d25
comparison
equal deleted inserted replaced
233:dae90ded1bcd 234:0498425202a4
31 } 31 }
32 32
33 if(selectedKeys.isEmpty()) 33 if(selectedKeys.isEmpty())
34 try { 34 try {
35 this.wait(); 35 this.wait();
36 } catch (InterruptedException e) {
37 throw new IOException("Error, Selector was interrupted!");
38 }
39 }
40 wakeFlag=false;
41 }
42 return selectedKeys.size();
43 }
44
45 @Override
46 public int select(long timeout) throws IOException {
47 selectedKeys = new HashSet<SelectionKey>();
48
49 synchronized(this) {
50 if (!wakeFlag){
51 for(SelectionKey key : keyList){
52 if(((SelectionKeySimulator<?>) key).isAble())
53 selectedKeys.add(key);
54 }
55
56 if(selectedKeys.isEmpty())
57 try {
58 this.wait(timeout);
36 } catch (InterruptedException e) { 59 } catch (InterruptedException e) {
37 throw new IOException("Error, Selector was interrupted!"); 60 throw new IOException("Error, Selector was interrupted!");
38 } 61 }
39 } 62 }
40 wakeFlag=false; 63 wakeFlag=false;
106 public SelectorProvider provider() { 129 public SelectorProvider provider() {
107 // TODO Auto-generated method stub 130 // TODO Auto-generated method stub
108 return null; 131 return null;
109 } 132 }
110 133
111 @Override
112 public int select(long timeout) throws IOException {
113 // TODO Auto-generated method stub
114 return 0;
115 }
116 134
117 @Override 135 @Override
118 public Selector wakeup() { 136 public Selector wakeup() {
119 synchronized(this){ 137 synchronized(this){
120 this.notifyAll(); 138 this.notifyAll();