Mercurial > hg > Members > tatsuki > Alice
changeset 70:f2d4a4686036
delete CodeSegment receive thread
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Feb 2012 20:09:18 +0900 |
parents | 1d4f2b72fb31 |
children | a3a2605e16a2 |
files | src/alice/codesegment/CodeSegmentManager.java src/alice/test/topology/ring/CheckMyName.java src/alice/test/topology/ring/FirstRingMessagePassing.java src/alice/test/topology/ring/RingMessagePassing.java |
diffstat | 4 files changed, 15 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/CodeSegmentManager.java Tue Feb 21 19:44:33 2012 +0900 +++ b/src/alice/codesegment/CodeSegmentManager.java Tue Feb 21 20:09:18 2012 +0900 @@ -10,45 +10,24 @@ private static CodeSegmentManager instance = new CodeSegmentManager(); public LinkedBlockingQueue<CodeSegment> readyQueue = new LinkedBlockingQueue<CodeSegment>(); - private ThreadPoolExecutor codeSegmentExecutor = new ThreadPoolExecutor(1, // initial number of threads + private ThreadPoolExecutor codeSegmentExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads Runtime.getRuntime().availableProcessors(), Integer.MAX_VALUE, // keepAliveTime TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); private Logger log = Logger.getLogger(CodeSegmentManager.class); - - private CodeSegmentManager() { - Runnable prepareThread = new Runnable() { - // TODO: remove this thread - @Override - public void run() { - while (true) { - try { - CodeSegment cs = readyQueue.take(); - codeSegmentExecutor.execute(cs); - log.debug(cs.getClass().getName()); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - }; - new Thread(prepareThread, "CodeSegmentManager").start(); - } - - public void create(CodeSegment cs) { - } + + private boolean debug = false; public static CodeSegmentManager get() { return instance; } public static void submit(CodeSegment cs) { - try { - CodeSegmentManager.get().readyQueue.put(cs); - } catch (InterruptedException e) { - e.printStackTrace(); + CodeSegmentManager csManager = CodeSegmentManager.get(); + csManager.codeSegmentExecutor.execute(cs); + if (csManager.debug) { + csManager.log.debug(cs.getClass().getName()); } }
--- a/src/alice/test/topology/ring/CheckMyName.java Tue Feb 21 19:44:33 2012 +0900 +++ b/src/alice/test/topology/ring/CheckMyName.java Tue Feb 21 20:09:18 2012 +0900 @@ -22,15 +22,15 @@ String host = this.host.asString(); logger.debug(host); if (host.equals("node0")) { - ods.put("local", "counter", new byte[conf.size]); + ods.put("local", "c", new byte[conf.size]); FirstRingMessagePassing cs1 = new FirstRingMessagePassing(System.nanoTime(), conf.count, conf.nodeNum); - cs1.counter.setKey("counter"); + cs1.counter.setKey("c"); RingFinish cs2 = new RingFinish("manager"); cs2.finish.setKey("finish"); } else { ods.close("manager"); RingMessagePassing cs1 = new RingMessagePassing(); - cs1.counter.setKey("counter"); + cs1.counter.setKey("c"); RingFinish cs2 = new RingFinish("right"); cs2.finish.setKey("finish"); }
--- a/src/alice/test/topology/ring/FirstRingMessagePassing.java Tue Feb 21 19:44:33 2012 +0900 +++ b/src/alice/test/topology/ring/FirstRingMessagePassing.java Tue Feb 21 20:09:18 2012 +0900 @@ -21,17 +21,17 @@ @Override public void run() { - ods.put("right", "counter", counter.val); + ods.put("right", "c", counter.val); if (counter.index > count) { ods.put("right", "finish", ValueFactory.createNilValue()); long endTime = System.nanoTime(); long time = endTime - startTime; - System.out.println(nodeNum + ", " + time / count); + System.out.println(nodeNum + ", " + time / (count * 1000000.0f)); return; } FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count, nodeNum); - cs.counter.setKey("counter"); + cs.counter.setKey("c"); } }
--- a/src/alice/test/topology/ring/RingMessagePassing.java Tue Feb 21 19:44:33 2012 +0900 +++ b/src/alice/test/topology/ring/RingMessagePassing.java Tue Feb 21 20:09:18 2012 +0900 @@ -10,9 +10,9 @@ @Override public void run() { - ods.put("right", "counter", this.counter.val); + ods.put("right", "c", this.counter.val); RingMessagePassing cs = new RingMessagePassing(); - cs.counter.setKey("counter"); + cs.counter.setKey("c"); } }