Mercurial > hg > FederatedLinda
diff src/fdl/MetaLinda.java @ 31:846c6c14cf04
worked?
author | kono |
---|---|
date | Fri, 22 Aug 2008 14:48:41 +0900 |
parents | fca6eec8016f |
children | 64071f8e2e0d |
line wrap: on
line diff
--- a/src/fdl/MetaLinda.java Thu Aug 21 18:46:40 2008 +0900 +++ b/src/fdl/MetaLinda.java Fri Aug 22 14:48:41 2008 +0900 @@ -14,6 +14,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.util.LinkedList; /** MetaLinda @@ -31,8 +32,7 @@ public FDLindaServ fds; public FederatedLinda fdl=null; public PSXLinda next=null; - private MetaReply replies=new MetaReply(0, 0, ts); - private MetaReply last=replies; + private LinkedList<MetaReply> replies=new LinkedList<MetaReply>(); public MetaLinda(TupleSpace ts,FDLindaServ fds) { this.ts = ts; @@ -49,7 +49,7 @@ } private void addReply(MetaReply r) { - last.next = r; last = r; + replies.add(r); } public PSXReply ck(int id) { @@ -100,14 +100,14 @@ public int sync(long timeout) { fds.checkTuple(timeout); - PSXReply r; - for(r=replies;r!=null&&r.next!=null;r = r.next) { - if (r.next.ready()) { - // ready() may modify replies list - r.next = r.next.next; + // copy replies to avoid insert during r.ready() + LinkedList<MetaReply> list = replies; + replies = new LinkedList<MetaReply>(); + for(MetaReply r:list) { + if (!r.ready()) { + addReply(r); } } - last = (MetaReply)r; if (fdl!=null) { try { fdl.sync(timeout);