Mercurial > hg > FederatedLinda
view src/fdl/MetaReply.java @ 71:0352536c33fa
(example: writer) get linda server addr from commandline arg.
author | kazz@e065701.local |
---|---|
date | Fri, 23 Oct 2009 14:11:07 +0900 |
parents | 64071f8e2e0d |
children | 8931a3e90c2a |
line wrap: on
line source
package fdl; import java.nio.ByteBuffer; public class MetaReply extends PSXReply { public int id; public TupleSpace ts; public MetaReply(int mode, int id,TupleSpace ts) { this.mode = mode; this.id = id; this.ts = ts; this.command = ByteBuffer.allocate(PSX.LINDA_HEADER_SIZE); } public MetaReply(int mode, int id, TupleSpace ts,PSXCallback callback) { this(mode,id,ts); this.callback = callback; } public MetaReply(int mode, int id, TupleSpace ts,ByteBuffer data, PSXCallback callback) { this(mode,id,ts); this.data = data; this.callback = callback; } void checkTuple() { ByteBuffer data = ts.IN(id, mode, command); if (data!=null) { this.data = data; mode = PSX.PSX_ANSWER; if (callback!=null) callback.callback(data); } } public boolean ready() { switch(mode) { case PSX.PSX_IN: case PSX.PSX_RD: checkTuple(); break; case PSX.PSX_CHECK: data = ts.check1(null, command); if (data!=null) { mode = PSX.PSX_ANSWER; } break; case PSX.PSX_OUT: command=PSX.setCommand(PSX.PSX_OUT, id, 0, data); ts.Out(null, command, data); return true; case PSX.PSX_UPDATE: // not implemented break; } return mode==PSX.PSX_ANSWER; } }