Mercurial > hg > RemoteEditor > REPSessionManager
diff 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 |
line wrap: on
line diff
--- a/rep/channel/SelectorSimulator.java Sun Aug 31 19:01:03 2008 +0900 +++ b/rep/channel/SelectorSimulator.java Sun Aug 31 19:02:34 2008 +0900 @@ -41,6 +41,29 @@ } return selectedKeys.size(); } + + @Override + public int select(long timeout) throws IOException { + selectedKeys = new HashSet<SelectionKey>(); + + synchronized(this) { + if (!wakeFlag){ + for(SelectionKey key : keyList){ + if(((SelectionKeySimulator<?>) key).isAble()) + selectedKeys.add(key); + } + + if(selectedKeys.isEmpty()) + try { + this.wait(timeout); + } catch (InterruptedException e) { + throw new IOException("Error, Selector was interrupted!"); + } + } + wakeFlag=false; + } + return selectedKeys.size(); + } @Override public int selectNow() throws IOException { @@ -108,11 +131,6 @@ return null; } - @Override - public int select(long timeout) throws IOException { - // TODO Auto-generated method stub - return 0; - } @Override public Selector wakeup() {