projet-donnees-reparties/linda/test/BasicTestCallback.java

50 lines
1.3 KiB
Java
Raw Normal View History

2021-11-27 16:50:33 +00:00
package linda.test;
import linda.*;
import linda.Linda.eventMode;
import linda.Linda.eventTiming;
public class BasicTestCallback {
private static Linda linda;
private static Tuple cbmotif;
2021-11-28 11:44:46 +00:00
2021-11-27 16:50:33 +00:00
private static class MyCallback implements Callback {
public void call(Tuple t) {
2021-11-28 11:44:46 +00:00
System.out.println("CB got " + t);
2021-11-27 16:50:33 +00:00
linda.eventRegister(eventMode.TAKE, eventTiming.IMMEDIATE, cbmotif, this);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
2021-11-28 11:44:46 +00:00
System.out.println("CB done with " + t);
2021-11-27 16:50:33 +00:00
}
}
public static void main(String[] a) {
linda = new linda.shm.CentralizedLinda();
// linda = new linda.server.LindaClient("//localhost:4000/MonServeur");
cbmotif = new Tuple(Integer.class, String.class);
linda.eventRegister(eventMode.TAKE, eventTiming.IMMEDIATE, cbmotif, new MyCallback());
Tuple t1 = new Tuple(4, 5);
System.out.println("(2) write: " + t1);
linda.write(t1);
Tuple t2 = new Tuple("hello", 15);
System.out.println("(2) write: " + t2);
linda.write(t2);
linda.debug("(2)");
Tuple t3 = new Tuple(4, "foo");
System.out.println("(2) write: " + t3);
linda.write(t3);
linda.debug("(2)");
}
}