21
|
1 package fdl;
|
|
2
|
|
3 import java.nio.ByteBuffer;
|
|
4
|
|
5 /**
|
|
6 * @author kono
|
|
7 * Meta Protocol Engine for each Linda Server
|
|
8 */
|
|
9
|
|
10 public class MetaLogEngine implements MetaEngine {
|
|
11 MetaLinda meta;
|
|
12 boolean running = true;
|
|
13 CommDebugHook commDebug;
|
|
14
|
|
15 public MetaLogEngine(MetaLinda meta) {
|
|
16 this.meta = meta;
|
|
17 }
|
|
18
|
|
19 PSXCallback monitor_callback_start =
|
|
20 new PSXCallback() {public void callback(ByteBuffer reply) {
|
37
|
21 meta.setTupleSpaceHook(commDebug = new CommDebugHook());
|
33
|
22 meta.out(PSX.META_MONITOR_DATA, null);
|
21
|
23 meta.in(PSX.META_MONITOR,monitor_callback);
|
|
24 }};
|
|
25 PSXCallback monitor_callback =
|
|
26 new PSXCallback() {public void callback(ByteBuffer reply) {
|
|
27 ByteBuffer data;
|
|
28 do {
|
|
29 data = commDebug.getLog();
|
|
30 if (data!=null) break;
|
97
|
31 meta.sync(0);
|
36
|
32 } while (running);
|
|
33 if (running) {
|
|
34 meta.out(PSX.META_MONITOR_DATA, data);
|
|
35 meta.in(PSX.META_MONITOR,monitor_callback);
|
|
36 }
|
21
|
37 }};
|
|
38
|
97
|
39 public void mainLoop(MetaLinda meta) {
|
21
|
40 meta.in(PSX.META_MONITOR,monitor_callback_start);
|
31
|
41 meta.in(PSX.META_STOP, new PSXCallback() {public void callback(ByteBuffer reply) {
|
|
42 running = false;}});
|
21
|
43 while(running)
|
97
|
44 meta.sync(0);
|
21
|
45 }
|
|
46 }
|