Mercurial > hg > Members > tatsuki > Alice
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 |
rev | line source |
---|---|
3 | 1 package alice.codesegment; |
2 | |
3 import java.util.concurrent.atomic.AtomicInteger; | |
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 | 6 import alice.datasegment.DataSegment; |
44 | 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 | 9 |
57 | 10 /** |
11 * InputDataSegment Manager | |
12 * keep tracking unbound/bound count | |
13 * @author kazz | |
14 * | |
15 */ | |
3 | 16 public class InputDataSegment { |
17 | |
119 | 18 public CodeSegment cs; |
57 | 19 private AtomicInteger count = new AtomicInteger(1); // 1 for no input data segments |
20 private AtomicInteger keyCount = new AtomicInteger(0); // number of DataSegments | |
3 | 21 |
22 public InputDataSegment(CodeSegment cs) { | |
23 this.cs = cs; | |
24 } | |
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 | 27 peek(receiver, managerKey, key, 0); |
3 | 28 } |
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 | 31 DataSegment.get(managerKey).peek(receiver, key, index, cs); |
3 | 32 } |
33 | |
65 | 34 public void peek(Receiver receiver, String key) { |
35 peek(receiver, key, 0); | |
36 } | |
37 | |
38 public void peek(Receiver receiver, String key, int index) { | |
39 DataSegment.getLocal().peek(receiver, key, index, cs); | |
40 } | |
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 | 43 take(receiver, managerKey, key, 0); |
3 | 44 } |
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 | 47 DataSegment.get(managerKey).take(receiver, key, index, cs); |
3 | 48 } |
7 | 49 |
65 | 50 public void take(Receiver receiver, String key) { |
51 take(receiver, key, 0); | |
52 } | |
53 | |
54 public void take(Receiver receiver, String key, int index) { | |
55 DataSegment.getLocal().take(receiver, key, index, cs); | |
56 } | |
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 | 59 receiver.index = val.index; |
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 | 62 receiver.obj = val.obj; |
19 | 63 receive(); |
64 } | |
65 | |
66 public void regist() { | |
67 count.getAndIncrement(); | |
68 keyCount.getAndIncrement(); | |
9 | 69 } |
70 | |
19 | 71 public void setKey() { |
72 if (keyCount.decrementAndGet() == 0) { | |
73 receive(); | |
74 } | |
75 } | |
76 | |
77 public void receive() { | |
8 | 78 if (count.decrementAndGet() == 0) { |
57 | 79 CodeSegmentManager.submit(cs); |
8 | 80 } |
81 } | |
32
2bfb796b0fa1
change method to create DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
28
diff
changeset
|
82 |
57 | 83 /** |
84 * InputDataSegment factory | |
85 * @param type PEEK or TAKE | |
86 * @return Receiver of DataSegment reply | |
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 | 91 |
3 | 92 } |