Mercurial > hg > Members > tatsuki > Alice
comparison src/main/java/alice/test/codesegment/api/UpdateCodeSegment.java @ 345:8f71c3e6f11d
Change directory structure Maven standard
author | sugi |
---|---|
date | Wed, 16 Apr 2014 18:26:07 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
344:9f97ec18f8c5 | 345:8f71c3e6f11d |
---|---|
1 package alice.test.codesegment.api; | |
2 | |
3 import org.msgpack.type.Value; | |
4 import org.msgpack.type.ValueFactory; | |
5 | |
6 import alice.codesegment.CodeSegment; | |
7 import alice.datasegment.CommandType; | |
8 import alice.datasegment.Receiver; | |
9 | |
10 public class UpdateCodeSegment extends CodeSegment { | |
11 Receiver ds1 = ids.create(CommandType.PEEK); | |
12 | |
13 @Override | |
14 public void run() { | |
15 UpdateCodeSegment cs1 = new UpdateCodeSegment(); | |
16 cs1.ds1.setKey("key", ds1.index); | |
17 Value[] array = ((Value)ds1.getVal()).asArrayValue().getElementArray(); | |
18 int val = array[0].asIntegerValue().getInt(); | |
19 if (val % 10 == 0) | |
20 System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB"); | |
21 if (val >= 10000000) { | |
22 System.exit(0); | |
23 } | |
24 array[0] = ValueFactory.createIntegerValue(val + 1); | |
25 ods.update("local", "key", array); | |
26 } | |
27 | |
28 } |