Mercurial > hg > RemoteEditor > Eclipse
view src/pathfinder/BlockingQnoSeMa/ChannelSimulator.java @ 83:3db21fae825a
pathfinder simulation without SessionManager
author | kent |
---|---|
date | Mon, 12 Nov 2007 17:53:48 +0900 |
parents | |
children |
line wrap: on
line source
package pathfinder.BlockingQnoSeMa; import java.util.concurrent.BlockingQueue; public class ChannelSimulator<P> { private BlockingQueue<P> qread; private BlockingQueue<P> qwrite; public ChannelSimulator(BlockingQueue<P> _a, BlockingQueue<P> _b){ qread = _a; qwrite = _b; } public P read(){ try { return qread.take(); } catch (InterruptedException e) { e.printStackTrace(); return null; } } public boolean write(P p){ try { qwrite.put(p); return true; } catch (InterruptedException e) { e.printStackTrace(); return false; } } public BlockingQueue<P> getReadQ(){ return qread; } public BlockingQueue<P> getWriteQ(){ return qwrite; } public void setReadQ(BlockingQueue<P> bq){ qread = bq; } public void setWriteQ(BlockingQueue<P> bq){ qwrite = bq; } public boolean readQisEmpty() { return qread.isEmpty(); } public boolean writeQisEmpty() { return qwrite.isEmpty(); } }