Mercurial > hg > RemoteEditor > REPSessionManager
changeset 210:3e0cd34d625d
*** empty log message ***
author | kent |
---|---|
date | Sat, 30 Aug 2008 14:35:53 +0900 |
parents | 1eec69035548 |
children | 44d502851c9e |
files | rep/channel/REPSelector.java rep/channel/SelectionKeySimulator.java rep/channel/SelectorSimulator.java |
diffstat | 3 files changed, 23 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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<P>(k)); } - return (Set<REPSelectionKey<P>>)newKeys; + return newKeys; }
--- 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;
--- 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<SelectionKey> keyList; private Set<SelectionKey> selectedKeys; + private boolean wakeFlag=false; public SelectorSimulator() { super(null); keyList = new HashSet<SelectionKey>(); } - //@SuppressWarnings("unchecked") public int select() throws IOException { selectedKeys = new HashSet<SelectionKey>(); 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<SelectionKey>(); + + 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