Mercurial > hg > Members > tatsuki > Alice
changeset 9:22afbb2919f1
execute() api
author | one |
---|---|
date | Thu, 12 Jan 2012 19:28:50 +0900 |
parents | 78b415d019de |
children | 5f7cce38b25c |
files | src/alice/codesegment/InputDataSegment.java src/alice/test/codesegment/StartCodeSegment.java src/alice/test/codesegment/TestAlice.java src/alice/test/codesegment/TestCodeSegment.java |
diffstat | 4 files changed, 24 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/InputDataSegment.java Thu Jan 12 16:02:28 2012 +0900 +++ b/src/alice/codesegment/InputDataSegment.java Thu Jan 12 19:28:50 2012 +0900 @@ -10,7 +10,7 @@ private ConcurrentHashMap<String, DataSegmentValue> inputDataSegments = new ConcurrentHashMap<String, DataSegmentValue>(); private CodeSegment cs; - private AtomicInteger count = new AtomicInteger(); + private AtomicInteger count = new AtomicInteger(1); // for execute() public InputDataSegment(CodeSegment cs) { this.cs = cs; @@ -36,6 +36,10 @@ public void reply(String key, DataSegmentValue val) { inputDataSegments.put(key, val); + execute(); + } + + public void execute() { if (count.decrementAndGet() == 0) { try { CodeSegmentManager.get().readyQueue.put(cs);
--- a/src/alice/test/codesegment/StartCodeSegment.java Thu Jan 12 16:02:28 2012 +0900 +++ b/src/alice/test/codesegment/StartCodeSegment.java Thu Jan 12 19:28:50 2012 +0900 @@ -12,8 +12,9 @@ public void run() { System.out.println("run StartCodeSegment"); - TestCodeSegment tcs = new TestCodeSegment(); - tcs.ids.peek("arg1", "local", "key1"); + CodeSegment cs = new TestCodeSegment(); + cs.ids.peek("arg1", "local", "key1"); + cs.ids.execute(); System.out.println("create TestCodeSegment"); Value val = ValueFactory.createRawValue("String data");
--- a/src/alice/test/codesegment/TestAlice.java Thu Jan 12 16:02:28 2012 +0900 +++ b/src/alice/test/codesegment/TestAlice.java Thu Jan 12 19:28:50 2012 +0900 @@ -1,17 +1,11 @@ package alice.test.codesegment; import alice.codesegment.CodeSegment; -import alice.codesegment.CodeSegmentManager; public class TestAlice { public static void main(String args[]) { - CodeSegment scs = new StartCodeSegment(); - try { - CodeSegmentManager.get().readyQueue.put(scs); - } catch (InterruptedException e) { - e.printStackTrace(); - } - + CodeSegment cs = new StartCodeSegment(); + cs.ids.execute(); } }
--- a/src/alice/test/codesegment/TestCodeSegment.java Thu Jan 12 16:02:28 2012 +0900 +++ b/src/alice/test/codesegment/TestCodeSegment.java Thu Jan 12 19:28:50 2012 +0900 @@ -1,6 +1,10 @@ package alice.test.codesegment; +import org.msgpack.type.Value; +import org.msgpack.type.ValueFactory; + import alice.codesegment.CodeSegment; +import alice.datasegment.DataSegment; import alice.datasegment.DataSegmentValue; public class TestCodeSegment extends CodeSegment { @@ -9,7 +13,16 @@ public void run() { DataSegmentValue data = ids.get("arg1"); System.out.println("index = " + data.index); - System.out.println("data = " + data.val.toString()); + System.out.println("data = " + data.val); + + if (data.index == 10) return; + + CodeSegment cs = new TestCodeSegment(); + cs.ids.peek("arg1", "local", "key1", data.index); + cs.ids.execute(); + + Value val = ValueFactory.createRawValue("String data"); + DataSegment.get("local").put("key1", val); } }