annotate src/alice/codesegment/InputDataSegment.java @ 192:a8b0d44bbe68 working

not use value object in bitonic
author e095732
date Thu, 07 Mar 2013 22:20:54 +0900
parents a85ff8dc16c1
children f151dea22b2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
1 package alice.codesegment;
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
2
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
3 import java.util.concurrent.atomic.AtomicInteger;
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
4
32
2bfb796b0fa1 change method to create DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
5 import alice.datasegment.CommandType;
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
6 import alice.datasegment.DataSegment;
44
73158dc54c59 fix peek api
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
7 import alice.datasegment.DataSegmentValue;
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
8 import alice.datasegment.Receiver;
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
9
57
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
10 /**
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
11 * InputDataSegment Manager
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
12 * keep tracking unbound/bound count
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
13 * @author kazz
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
14 *
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
15 */
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
16 public class InputDataSegment {
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
17
119
f84e1684c6be put NULL in CS
sugi
parents: 65
diff changeset
18 public CodeSegment cs;
57
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
19 private AtomicInteger count = new AtomicInteger(1); // 1 for no input data segments
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
20 private AtomicInteger keyCount = new AtomicInteger(0); // number of DataSegments
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
21
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
22 public InputDataSegment(CodeSegment cs) {
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
23 this.cs = cs;
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
24 }
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
25
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
26 public void peek(Receiver receiver, String managerKey, String key) {
18
72dd27d952b0 change InputDataSegment API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
27 peek(receiver, managerKey, key, 0);
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
28 }
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
29
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
30 public void peek(Receiver receiver, String managerKey, String key, int index) {
18
72dd27d952b0 change InputDataSegment API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
31 DataSegment.get(managerKey).peek(receiver, key, index, cs);
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
32 }
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
33
65
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
34 public void peek(Receiver receiver, String key) {
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
35 peek(receiver, key, 0);
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
36 }
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
37
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
38 public void peek(Receiver receiver, String key, int index) {
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
39 DataSegment.getLocal().peek(receiver, key, index, cs);
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
40 }
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
41
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
42 public void take(Receiver receiver, String managerKey, String key) {
18
72dd27d952b0 change InputDataSegment API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
43 take(receiver, managerKey, key, 0);
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
44 }
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
45
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
46 public void take(Receiver receiver, String managerKey, String key, int index) {
18
72dd27d952b0 change InputDataSegment API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
47 DataSegment.get(managerKey).take(receiver, key, index, cs);
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
48 }
7
352eb19d837d implements reply of LocalDataSegment
one
parents: 5
diff changeset
49
65
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
50 public void take(Receiver receiver, String key) {
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
51 take(receiver, key, 0);
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
52 }
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
53
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
54 public void take(Receiver receiver, String key, int index) {
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
55 DataSegment.getLocal().take(receiver, key, index, cs);
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
56 }
ca42a2c8ac22 add local access api
kazz
parents: 57
diff changeset
57
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
58 public void reply(Receiver receiver, DataSegmentValue val) {
18
72dd27d952b0 change InputDataSegment API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
59 receiver.index = val.index;
72dd27d952b0 change InputDataSegment API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
60 receiver.val = val.val;
28
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
61 receiver.from = val.from;
190
a85ff8dc16c1 add Object data
one
parents: 131
diff changeset
62 receiver.obj = val.obj;
19
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
63 receive();
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
64 }
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
65
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
66 public void regist() {
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
67 count.getAndIncrement();
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
68 keyCount.getAndIncrement();
9
22afbb2919f1 execute() api
one
parents: 8
diff changeset
69 }
22afbb2919f1 execute() api
one
parents: 8
diff changeset
70
19
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
71 public void setKey() {
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
72 if (keyCount.decrementAndGet() == 0) {
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
73 receive();
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
74 }
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
75 }
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
76
e7867328a2fb change execute() API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
77 public void receive() {
8
78b415d019de Local DS and CS work! maybe...
one
parents: 7
diff changeset
78 if (count.decrementAndGet() == 0) {
57
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
79 CodeSegmentManager.submit(cs);
8
78b415d019de Local DS and CS work! maybe...
one
parents: 7
diff changeset
80 }
78b415d019de Local DS and CS work! maybe...
one
parents: 7
diff changeset
81 }
32
2bfb796b0fa1 change method to create DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
82
57
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
83 /**
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
84 * InputDataSegment factory
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
85 * @param type PEEK or TAKE
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
86 * @return Receiver of DataSegment reply
7fa9ddb31f64 add comment
one
parents: 44
diff changeset
87 */
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
88 public Receiver create(CommandType type) {
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
89 return new Receiver(this, type);
32
2bfb796b0fa1 change method to create DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
90 }
18
72dd27d952b0 change InputDataSegment API
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
91
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
92 }