|
27 | 27 | import java.util.List; |
28 | 28 | import java.util.Map; |
29 | 29 | import java.util.Map.Entry; |
| 30 | +import java.util.Optional; |
30 | 31 | import java.util.Set; |
31 | 32 | import java.util.concurrent.Executor; |
32 | 33 | import java.util.concurrent.ExecutorService; |
@@ -186,8 +187,18 @@ public class Exec implements Module { |
186 | 187 | ImmutableMap |
187 | 188 | .of( |
188 | 189 | "cached", (name, n, tf, opts) -> Executors.newCachedThreadPool(tf.get()), |
189 | | - "fixed", (name, n, tf, opts) -> Executors.newFixedThreadPool(n, tf.get()), |
190 | | - "scheduled", (name, n, tf, opts) -> Executors.newScheduledThreadPool(n, tf.get()), |
| 190 | + "fixed", (name, n, tf, opts) -> { |
| 191 | + Optional<Integer> size = Optional.ofNullable( |
| 192 | + opts.containsKey("size") ? Integer.parseInt(opts.get("size").toString()) : null |
| 193 | + ); |
| 194 | + return Executors.newFixedThreadPool(size.orElse(n), tf.get()); |
| 195 | + }, |
| 196 | + "scheduled", (name, n, tf, opts) -> { |
| 197 | + Optional<Integer> size = Optional.ofNullable( |
| 198 | + opts.containsKey("size") ? Integer.parseInt(opts.get("size").toString()) : null |
| 199 | + ); |
| 200 | + return Executors.newScheduledThreadPool(size.orElse(n), tf.get()); |
| 201 | + }, |
191 | 202 | "forkjoin", (name, n, tf, opts) -> { |
192 | 203 | boolean asyncMode = Boolean.parseBoolean(opts.getOrDefault("asyncMode", "false") |
193 | 204 | .toString()); |
|
0 commit comments