Mercurial > hg > FederatedLinda
view src/fdl/test/transfer/three/TestGet.java @ 50:0025a8582d5f
Federated Linda Ring three
author | axmo |
---|---|
date | Fri, 12 Dec 2008 19:38:40 +0900 |
parents | |
children |
line wrap: on
line source
package fdl.test.transfer.three; import java.io.IOException; import java.nio.ByteBuffer; import fdl.FederatedLinda; import fdl.PSXLinda; import fdl.PSXReply; public class TestGet extends Thread { PSXLinda psxget; FederatedLinda fdlget; private int port; String host = "127.0.0.1"; private ByteBuffer data = ByteBuffer.allocate(10); public TestGet(int port1) { this.port = port1; } public void run(){ int id = 10; int i; fdlget = FederatedLinda.init(); boolean connecttest = true; while(connecttest){ try { getData(id); i = data.getInt(); System.out.println(i); connecttest = false; } catch (IOException e) { e.printStackTrace(); connecttest = true; } } } private void getData(int id) throws IOException { psxget = fdlget.open(host, port); PSXReply get = psxget.in(id); boolean running = false; while(running){ if(get.ready()){ data = get.getData(); running = false; fdlget.sync(0); break; } fdlget.sync(); } } }