comparison rep/channel/SelectorSimulator.java @ 203:4c0a94836357 simullator-nio-both-worked

*** empty log message ***
author kono
date Sat, 30 Aug 2008 11:21:43 +0900
parents 8d7c74610b05
children 0607cc699ba3
comparison
equal deleted inserted replaced
202:ffedaf382e0c 203:4c0a94836357
16 public SelectorSimulator() { 16 public SelectorSimulator() {
17 super(null); 17 super(null);
18 keyList = new HashSet<SelectionKey>(); 18 keyList = new HashSet<SelectionKey>();
19 } 19 }
20 20
21 //@SuppressWarnings("unchecked")
22 public int select() throws IOException { 21 public int select() throws IOException {
23 selectedKeys = new HashSet<SelectionKey>(); 22 selectedKeys = new HashSet<SelectionKey>();
24 23
25 synchronized(this) { 24 synchronized(this) {
26 25
27 while(selectedKeys.isEmpty()){ 26 while(selectedKeys.isEmpty()){
28 for(SelectionKey key : keyList){ 27 for(SelectionKey key : keyList){
29 if(((SelectionKeySimulator) key).isAble()) 28 if(((SelectionKeySimulator<?>) key).isAble())
30 selectedKeys.add(key); 29 selectedKeys.add(key);
31 } 30 }
32 31
33 if(selectedKeys.isEmpty()) 32 if(selectedKeys.isEmpty())
34 try { 33 try {
59 // REPSelectionKeyを生成しないように注意 58 // REPSelectionKeyを生成しないように注意
60 newKeys.add(new SelectionKeySimulator<P>(k)); 59 newKeys.add(new SelectionKeySimulator<P>(k));
61 } 60 }
62 return newKeys;//(Set<REPSelectionKey<P>>)newKeys; 61 return newKeys;//(Set<REPSelectionKey<P>>)newKeys;
63 } 62 }
64
65 /*
66 public <T> SelectionKeySimulator register(ChannelSimulator<T> cs, int opt, Object handler){
67 SelectionKeySimulator key = new SelectionKeySimulator(cs, opt, this);
68 key.attach(handler);
69 keyList.add(key);
70 return key;
71 }*/
72 63
73 public <T> SelectionKey getKey(ChannelSimulator<T> channel){ 64 public <T> SelectionKey getKey(ChannelSimulator<T> channel){
74 for(SelectionKey key : keyList){ 65 for(SelectionKey key : keyList){
75 if(key.channel() == channel) 66 if(key.channel() == channel)
76 return key; 67 return key;