Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/channel/REPSelector.java @ 194:be219ba8b39c
*** empty log message ***
author | kono |
---|---|
date | Fri, 29 Aug 2008 20:25:46 +0900 |
parents | 63701e2a2fe8 |
children | 3e0cd34d625d |
line wrap: on
line diff
--- a/rep/channel/REPSelector.java Fri Aug 29 20:02:23 2008 +0900 +++ b/rep/channel/REPSelector.java Fri Aug 29 20:25:46 2008 +0900 @@ -7,9 +7,11 @@ import java.nio.channels.Selector; import java.nio.channels.spi.AbstractSelector; import java.nio.channels.spi.SelectorProvider; +import java.util.HashSet; import java.util.Set; -public class REPSelector extends Selector{ + +public class REPSelector<P> extends Selector{ Selector selector; @@ -17,11 +19,11 @@ this.selector = selector; } - public static REPSelector create() throws IOException{ + public static <T>REPSelector<T> create() throws IOException{ if(REPServerSocketChannel.isSimulation){ - return new SelectorSimulator(); + return new SelectorSimulator<T>(); } - return new REPSelector(SelectorProvider.provider().openSelector()); + return new REPSelector<T>(SelectorProvider.provider().openSelector()); } @Override @@ -61,12 +63,6 @@ @Override public Set<SelectionKey> selectedKeys() { - /* - Set<SelectionKey> keys = new HashSet<SelectionKey>(); - for (SelectionKey key: selector.selectedKeys()){ - keys.add(new SelectionKeySimulator(new REPSocketChannel<?>(), key.readyOps(), selector)); - new SelectionKey(); - }*/ return selector.selectedKeys(); } @@ -78,16 +74,16 @@ public SelectionKey register(SelectableChannel ch, int ops, Object att) throws ClosedChannelException{ return ch.register(selector, ops, att); } - public SelectionKey register(SelectableChannel ch, int ops) throws ClosedChannelException{ - return register(ch, ops, null); + + public Set<REPSelectionKey<P>> selectedKeys1() { + Set<SelectionKey> keys = selector.selectedKeys(); + HashSet<REPSelectionKey<P>> newKeys = new HashSet<REPSelectionKey<P>>(); + for(SelectionKey k: keys) { + newKeys.add(new REPSelectionKey<P>(k)); + } + return (Set<REPSelectionKey<P>>)newKeys; } - /* - public SelectionKey register(REPSocketChannel<?> ch, int ops, Object att) throws ClosedChannelException{ - return ch.register(selector, ops, att); - } - public SelectionKey register(REPServerSocketChannel<?> ch, int ops, Object att) throws ClosedChannelException{ - return ch.register(selector, ops, att); - }*/ + }