Mercurial > hg > Database > Alice
view src/alice/codesegment/CodeSegmentManager.java @ 335:2f003d5703d5 META_CODESEGMENT
Meta CodeSegment Test
author | sugi |
---|---|
date | Mon, 14 Apr 2014 15:46:29 +0900 |
parents | 1caa6970cf01 |
children | 5fa184113850 |
line wrap: on
line source
package alice.codesegment; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; public class CodeSegmentManager { private static CodeSegmentManager instance = new CodeSegmentManager(); 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 logger = Logger.getLogger(CodeSegmentManager.class); public static CodeSegmentManager get() { return instance; } public static void submit(CodeSegment cs) { if (cs.hasMeta()){ try { CodeSegment meta = cs.getMetaClass().newInstance(); meta.setCodeSegment(cs); meta.setKey(); } catch (Exception e) { e.printStackTrace(); } } else { CodeSegmentManager csManager = CodeSegmentManager.get(); csManager.codeSegmentExecutor.execute(cs); if (csManager.logger.isDebugEnabled()) { csManager.logger.debug(cs.getClass().getName()); } } } }