Mercurial > hg > FederatedLinda
view src/fdl/MetaLinda.java @ 30:fca6eec8016f
*** empty log message ***
author | kono |
---|---|
date | Thu, 21 Aug 2008 18:46:40 +0900 |
parents | 132c9bc28d6b |
children | 846c6c14cf04 |
line wrap: on
line source
/* * @(#)MetaLinda.java 1.1 06/04/01 * * Copyright 2008 Shinji KONO * Meta Lidna Trasport layer of Meta Linda API */ package fdl; import java.io.IOException; import java.nio.ByteBuffer; /** MetaLinda * * @author Shinji Kono * meta tuple interface in Linda Server */ public class MetaLinda implements PSXLinda { public TupleSpace ts; public FDLindaServ fds; public FederatedLinda fdl=null; public PSXLinda next=null; private MetaReply replies=new MetaReply(0, 0, ts); private MetaReply last=replies; public MetaLinda(TupleSpace ts,FDLindaServ fds) { this.ts = ts; this.fds = fds; } public PSXReply in(int id) { return null; } public void in(int id, PSXCallback callback) { MetaReply r = new MetaReply(PSX.PSX_IN,id,ts, callback); addReply(r); } private void addReply(MetaReply r) { last.next = r; last = r; } public PSXReply ck(int id) { MetaReply r = new MetaReply(PSX.PSX_CHECK,id,ts); return r; } public void ck(int id, PSXCallback callback) { MetaReply r = new MetaReply(PSX.PSX_CHECK,id,ts,callback); addReply(r); } public PSXReply out(int id, ByteBuffer data) { MetaReply r = new MetaReply(PSX.PSX_OUT,id,ts,data,null); addReply(r); return r; } public PSXReply update(int id, ByteBuffer data) { MetaReply r = new MetaReply(PSX.PSX_UPDATE,id,ts,data,null); return r; } public void update(int id, ByteBuffer data,PSXCallback callback) { MetaReply r = new MetaReply(PSX.PSX_UPDATE,id,ts,data,callback); addReply(r); } public PSXReply rd(int id) { MetaReply r = new MetaReply(PSX.PSX_RD,id,ts); return r; } public void rd(int id, PSXCallback callback) { MetaReply r = new MetaReply(PSX.PSX_RD,id,ts,callback); addReply(r); } public PSXLinda add(PSXLinda linda) { next = linda; return this; } public int sync() { return sync(0); } 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; } } last = (MetaReply)r; if (fdl!=null) { try { fdl.sync(timeout); } catch (IOException e) { e.printStackTrace(); } } return 0; } public void send(ByteBuffer command, ByteBuffer data) { } } /* end */