langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/PooledSjavac.java
equal
deleted
inserted
replaced
22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package com.sun.tools.sjavac.comp; |
25 package com.sun.tools.sjavac.comp; |
26 |
26 |
|
27 import java.io.Writer; |
27 import java.util.Objects; |
28 import java.util.Objects; |
28 import java.util.concurrent.ExecutorService; |
29 import java.util.concurrent.ExecutorService; |
29 import java.util.concurrent.Executors; |
30 import java.util.concurrent.Executors; |
30 import java.util.concurrent.TimeUnit; |
31 import java.util.concurrent.TimeUnit; |
31 |
32 |
32 import com.sun.tools.sjavac.Log; |
33 import com.sun.tools.sjavac.Log; |
33 import com.sun.tools.sjavac.server.CompilationResult; |
|
34 import com.sun.tools.sjavac.server.Sjavac; |
34 import com.sun.tools.sjavac.server.Sjavac; |
35 |
35 |
36 /** |
36 /** |
37 * An sjavac implementation that limits the number of concurrent calls by |
37 * An sjavac implementation that limits the number of concurrent calls by |
38 * wrapping invocations in Callables and delegating them to a FixedThreadPool. |
38 * wrapping invocations in Callables and delegating them to a FixedThreadPool. |
52 this.delegate = delegate; |
52 this.delegate = delegate; |
53 pool = Executors.newFixedThreadPool(poolsize); |
53 pool = Executors.newFixedThreadPool(poolsize); |
54 } |
54 } |
55 |
55 |
56 @Override |
56 @Override |
57 public CompilationResult compile(String[] args) { |
57 public int compile(String[] args, Writer out, Writer err) { |
58 try { |
58 try { |
59 return pool.submit(() -> { |
59 return pool.submit(() -> { |
60 return delegate.compile(args); |
60 return delegate.compile(args, out, err); |
61 }).get(); |
61 }).get(); |
62 } catch (Exception e) { |
62 } catch (Exception e) { |
63 e.printStackTrace(); |
63 e.printStackTrace(); |
64 throw new RuntimeException("Error during compile", e); |
64 throw new RuntimeException("Error during compile", e); |
65 } |
65 } |