Mercurial > hg > Members > tatsuki > Alice
view src/alice/test/codesegment/api/UpdateCodeSegment.java @ 212:b5daccf36104 working
add Receiver state pattern
author | one |
---|---|
date | Wed, 27 Mar 2013 17:30:52 +0900 |
parents | 3fcd88d356cb |
children | fec0726bb126 |
line wrap: on
line source
package alice.test.codesegment.api; import org.msgpack.type.Value; import org.msgpack.type.ValueFactory; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class UpdateCodeSegment extends CodeSegment { Receiver ds1 = ids.create(CommandType.PEEK); @Override public void run() { UpdateCodeSegment cs1 = new UpdateCodeSegment(); cs1.ds1.setKey("key", ds1.data.index); Value[] array = ds1.data.val.asArrayValue().getElementArray(); int val = array[0].asIntegerValue().getInt(); if (val % 10 == 0) System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB"); if (val >= 10000000) { System.exit(0); } array[0] = ValueFactory.createIntegerValue(val + 1); ods.update("local", "key", array); } }