Mercurial > hg > Members > kazz > Alice
changeset 2:a57bf4ff773a default tip
add DataSegmentManager and CodeSegmentManager
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Jun 2011 13:23:03 +0900 |
parents | 67df4248b947 |
children | |
files | src/alice/CodeSegment.java src/alice/CodeSegmentManager.java src/alice/DataSegment.java src/alice/DataSegmentManager.java src/alice/Segment.java |
diffstat | 5 files changed, 40 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/CodeSegment.java Sun Jun 05 13:45:36 2011 +0900 +++ b/src/alice/CodeSegment.java Tue Jun 07 13:23:03 2011 +0900 @@ -1,8 +1,11 @@ package alice; -import java.util.LinkedList; +import java.util.concurrent.ConcurrentHashMap; public abstract class CodeSegment extends Segment { - LinkedList<CodeSegment> waitingSegments = new LinkedList<CodeSegment>(); - LinkedList<CodeSegment> startingSegments = new LinkedList<CodeSegment>(); + + ConcurrentHashMap<String, DataSegment> waitingSegments = new ConcurrentHashMap<String, DataSegment>(); + ConcurrentHashMap<String, DataSegment> startingSegments = new ConcurrentHashMap<String, DataSegment>(); + + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/CodeSegmentManager.java Tue Jun 07 13:23:03 2011 +0900 @@ -0,0 +1,20 @@ +package alice; + +import java.util.concurrent.ConcurrentHashMap; + +public class CodeSegmentManager { + + ConcurrentHashMap<String, CodeSegment> codeSegments = new ConcurrentHashMap<String, CodeSegment>(); + + void regist(String id, CodeSegment cs) { + if (codeSegments.containsKey(id)) + // TODO: use Logger + System.err.println("error"); + codeSegments.put(id, cs); + } + + CodeSegment getCodeSegment(String id) { + return codeSegments.get(id); + } + +}
--- a/src/alice/DataSegment.java Sun Jun 05 13:45:36 2011 +0900 +++ b/src/alice/DataSegment.java Tue Jun 07 13:23:03 2011 +0900 @@ -1,10 +1,12 @@ package alice; -import java.util.LinkedList; +import java.util.concurrent.ConcurrentHashMap; public abstract class DataSegment extends Segment { - LinkedList<CodeSegment> waitingSegments = new LinkedList<CodeSegment>(); - LinkedList<CodeSegment> startingSegments = new LinkedList<CodeSegment>(); - - + + ConcurrentHashMap<String, CodeSegment> waitingSegments = new ConcurrentHashMap<String, CodeSegment>(); + ConcurrentHashMap<String, CodeSegment> startingSegments = new ConcurrentHashMap<String, CodeSegment>(); + + + }