# HG changeset patch # User kent # Date 1220074553 -32400 # Node ID 3e0cd34d625dc605da84abad31cb4232ebfcfb2e # Parent 1eec69035548351cfb2f11dad4134fead95f214e *** empty log message *** diff -r 1eec69035548 -r 3e0cd34d625d rep/channel/REPSelector.java --- a/rep/channel/REPSelector.java Sat Aug 30 12:31:47 2008 +0900 +++ b/rep/channel/REPSelector.java Sat Aug 30 14:35:53 2008 +0900 @@ -81,7 +81,7 @@ for(SelectionKey k: keys) { newKeys.add(new REPSelectionKey

(k)); } - return (Set>)newKeys; + return newKeys; } diff -r 1eec69035548 -r 3e0cd34d625d rep/channel/SelectionKeySimulator.java --- a/rep/channel/SelectionKeySimulator.java Sat Aug 30 12:31:47 2008 +0900 +++ b/rep/channel/SelectionKeySimulator.java Sat Aug 30 14:35:53 2008 +0900 @@ -25,6 +25,7 @@ selector = k.selector(); } + public boolean isAble() { if ( (interestOpt&OP_READ)!=0 && isReadable() ) return true; diff -r 1eec69035548 -r 3e0cd34d625d rep/channel/SelectorSimulator.java --- a/rep/channel/SelectorSimulator.java Sat Aug 30 12:31:47 2008 +0900 +++ b/rep/channel/SelectorSimulator.java Sat Aug 30 14:35:53 2008 +0900 @@ -12,21 +12,21 @@ private Set keyList; private Set selectedKeys; + private boolean wakeFlag=false; public SelectorSimulator() { super(null); keyList = new HashSet(); } - //@SuppressWarnings("unchecked") public int select() throws IOException { selectedKeys = new HashSet(); synchronized(this) { - while(selectedKeys.isEmpty()){ + while(selectedKeys.isEmpty() && !wakeFlag){ for(SelectionKey key : keyList){ - if(((SelectionKeySimulator) key).isAble()) + if(((SelectionKeySimulator) key).isAble()) selectedKeys.add(key); } @@ -37,6 +37,20 @@ throw new IOException("Error, Selector was interrupted!"); } } + wakeFlag=false; + } + return selectedKeys.size(); + } + + @Override + public int selectNow() throws IOException { + selectedKeys = new HashSet(); + + synchronized(this) { + for(SelectionKey key : keyList){ + if(((SelectionKeySimulator) key).isAble()) + selectedKeys.add(key); + } } return selectedKeys.size(); } @@ -101,15 +115,11 @@ } @Override - public int selectNow() throws IOException { - // TODO Auto-generated method stub - return 0; - } - - @Override public Selector wakeup() { - // TODO Auto-generated method stub - return null; + synchronized(this){ + this.notifyAll(); + } + return this; } @Override