# HG changeset patch # User one # Date 1274857043 -32400 # Node ID d671c78d3757b3f85d34ed7eed8f5bc6edc77ae4 # Parent 270093b61001d1ef7625ac91d85aad66d3b65865 share selector in FDLindaServe and FederatedLinda diff -r 270093b61001 -r d671c78d3757 src/fdl/FederatedLinda.java --- a/src/fdl/FederatedLinda.java Wed May 26 15:45:56 2010 +0900 +++ b/src/fdl/FederatedLinda.java Wed May 26 15:57:23 2010 +0900 @@ -17,6 +17,7 @@ import java.nio.channels.ClosedSelectorException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; +import java.nio.channels.spi.AbstractSelector; import java.util.Hashtable; import java.util.Iterator; import java.util.logging.Level; @@ -49,20 +50,28 @@ public PSXQueue q_top,q_end; public PSXReply r_top,r_end; - public Hashtable seqHash; + public Hashtable seqHash = new Hashtable(); public static FederatedLinda init() { FederatedLinda fdl = new FederatedLinda(); return fdl; } + public static FederatedLinda init(Selector selector) { + FederatedLinda fdl = new FederatedLinda(selector); + return fdl; + } + private FederatedLinda() { try { selector = Selector.open(); } catch (IOException e) { e.printStackTrace(); } - seqHash = new Hashtable(); + } + + public FederatedLinda(Selector selector) { + this.selector = selector; } public PSXLinda open(String _host,int _port) @@ -222,6 +231,7 @@ public void wakeup() { selector.wakeup(); } + } /* end */ diff -r 270093b61001 -r d671c78d3757 src/fdl/MetaLinda.java --- a/src/fdl/MetaLinda.java Wed May 26 15:45:56 2010 +0900 +++ b/src/fdl/MetaLinda.java Wed May 26 15:57:23 2010 +0900 @@ -30,13 +30,14 @@ public TupleSpace ts; public FDLindaServ fds; - public FederatedLinda fdl=FederatedLinda.init(); + public FederatedLinda fdl; public PSXLinda next=null; public LinkedList replies=new LinkedList(); public MetaLinda(TupleSpace ts,FDLindaServ fds) { this.ts = ts; this.fds = fds; + fdl=FederatedLinda.init(fds.selector); } public PSXLinda open(String _host,int _port) @@ -115,7 +116,7 @@ * Meta Sync with no wait */ public int sync() { - fdl.sync(); + fdl.queueExec(); fds.checkTuple(); // fdl sync is also handled here return metaSync(); } @@ -125,7 +126,7 @@ * @param timeout wait timeout msec, if 0 wait indefinitely */ public int sync(long timeout) { - fdl.sync(); + fdl.queueExec(); fds.checkTuple(timeout); // fdl sync is also handled here return metaSync(); }