Mercurial > hg > RemoteEditor > REPSessionManager
view rep/simulator/ChannelSimulator.java @ 140:01062be677e9
*** empty log message ***
author | kono |
---|---|
date | Wed, 27 Aug 2008 20:23:39 +0900 |
parents | 5b1a0574b406 |
children |
line wrap: on
line source
package rep.simulator; import java.io.IOException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.spi.SelectorProvider; public class ChannelSimulator<P> extends SelectableChannelSimulator<P>{ //private BlockingQueue<P> qread; //private BlockingQueue<P> qwrite; //private SelectorSimulator<P> waitingSelector; protected NetworkSimulator<P> ns; /** Constructors. */ public ChannelSimulator(NetworkSimulator<P> _ns){ this(_ns, null); } public ChannelSimulator(NetworkSimulator<P> _ns, SelectorSimulator<P> _selector){ ns = _ns; //ns = NetworkSimulator.singleton(); //どっちがいい? } public ChannelSimulator<P> createConjugatedChannel() { ChannelSimulator<P> ret = new ChannelSimulator<P>(ns); ret.qread=qwrite; ret.qwrite=qread; ret.readSelector=writeSelector; ret.writeSelector=readSelector; return ret; } /** Connecting methods */ // for clients. public boolean connect(int ip){ return ns.connect(ip, this); } public ChannelSimulator<P> accept(){ return null; } /* return state of the Queue(debug) */ /* public boolean readQisEmpty() { return qread.isEmpty(); } public boolean writeQisEmpty() { return qwrite.isEmpty(); } */ @Override public boolean isAcceptable() { return false; } @Override public boolean isReadable() { synchronized (qread){ return !qread.isEmpty(); } } @Override public boolean isWritable() { return true; } public SelectionKeySimulator<P> keyFor(SelectorSimulator<P> selector2) { return (SelectionKeySimulator<P>) selector2.getKey(this); } @Override public Object blockingLock() { // TODO Auto-generated method stub return null; } @Override public SelectableChannel configureBlocking(boolean block) throws IOException { // TODO Auto-generated method stub return null; } @Override public boolean isBlocking() { // TODO Auto-generated method stub return false; } @Override public boolean isRegistered() { // TODO Auto-generated method stub return false; } @Override public SelectionKey keyFor(Selector sel) { // TODO Auto-generated method stub return null; } @Override public SelectorProvider provider() { // TODO Auto-generated method stub return null; } @Override public SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException { // TODO Auto-generated method stub return null; } @Override public int validOps() { // TODO Auto-generated method stub return 0; } @Override protected void implCloseChannel() throws IOException { // TODO Auto-generated method stub } }