annotate src/alice/codesegment/CodeSegmentManager.java @ 6:c78a1cc2cd8f

implements Reply
author one
date Thu, 12 Jan 2012 13:19:04 +0900
parents
children 352eb19d837d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
1 package alice.codesegment;
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
2
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
3 import java.util.concurrent.ConcurrentHashMap;
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
4 import java.util.concurrent.LinkedBlockingQueue;
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
5
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
6 public class CodeSegmentManager {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
7 private static CodeSegmentManager instance = new CodeSegmentManager();
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
8 private LinkedBlockingQueue<Reply> replyQueue = new LinkedBlockingQueue<Reply>();
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
9 private ConcurrentHashMap<Integer, CodeSegment> seqHash = new ConcurrentHashMap<Integer, CodeSegment>();
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
10
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
11 private CodeSegmentManager() {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
12 Runnable replyThread = new Runnable() {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
13
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
14 @Override
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
15 public void run() {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
16 while (true) {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
17 try {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
18 Reply reply = replyQueue.take();
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
19
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
20 } catch (InterruptedException e) {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
21 e.printStackTrace();
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
22 }
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
23 }
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
24
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
25 }
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
26 };
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
27 }
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
28
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
29 public void create(CodeSegment cs) {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
30 }
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
31
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
32 public static CodeSegmentManager get() {
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
33 return instance;
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
34 }
c78a1cc2cd8f implements Reply
one
parents:
diff changeset
35 }