Skip to content

Commit

Permalink
Merge pull request wisdom-framework#554 from remi-parain/master
Browse files Browse the repository at this point in the history
expose threadpool allowCoreThreadTimeOut property in config for ManagedExecutorService
  • Loading branch information
cescoffier committed Jun 7, 2016
2 parents 1156768 + 69c796b commit 08f3d23
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private void createExecutor(String name, Configuration conf) {
5,
25,
5000,
true,
Integer.MAX_VALUE,
Thread.NORM_PRIORITY,
ecs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public ManagedExecutorServiceImpl(String name, Configuration configuration, List
configuration.getIntegerWithDefault("coreSize", 5),
configuration.getIntegerWithDefault("maxSize", 25),
configuration.getDuration("keepAlive", TimeUnit.MILLISECONDS, 5000),
configuration.getBooleanWithDefault("allowCoreThreadTimeOut", true),
configuration.getIntegerWithDefault("workQueueCapacity",
Integer.MAX_VALUE),
configuration.getIntegerWithDefault("priority", Thread.NORM_PRIORITY),
Expand All @@ -56,6 +57,7 @@ public ManagedExecutorServiceImpl(
int coreSize,
int maxSize,
long keepAlive,
boolean allowCoreThreadTimeOut,
int workQueueCapacity,
int priority,
List<ExecutionContextService> ecs) {
Expand All @@ -82,7 +84,7 @@ public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
System.out.println("REJECTED EXECUTION : " + r);
}
});
executor.allowCoreThreadTimeOut(true);
executor.allowCoreThreadTimeOut(allowCoreThreadTimeOut);
setInternalPool(executor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class ManagedExecutorServiceImplTest {
10,
25,
1000,
true,
20,
Thread.NORM_PRIORITY,
null);
Expand Down Expand Up @@ -328,15 +329,15 @@ public void run() {
@Test
public void testCreationWithUnboundQueue() throws ExecutionException, InterruptedException {
ManagedExecutorServiceImpl service = new ManagedExecutorServiceImpl("unbound",
ManagedExecutorService.ThreadType.POOLED, 60000, 10, 25, 1000,
ManagedExecutorService.ThreadType.POOLED, 60000, 10, 25, 1000, true,
Integer.MAX_VALUE, Thread.NORM_PRIORITY, null);
assertThat(service.getQueue()).isInstanceOf(LinkedBlockingQueue.class);
}

@Test
public void testCreationWithHandOffQueue() throws ExecutionException, InterruptedException {
ManagedExecutorServiceImpl service = new ManagedExecutorServiceImpl("unbound",
ManagedExecutorService.ThreadType.POOLED, 60000, 10, 25, 1000,
ManagedExecutorService.ThreadType.POOLED, 60000, 10, 25, 1000, true,
0, Thread.NORM_PRIORITY, null);
assertThat(service.getQueue()).isInstanceOf(SynchronousQueue.class);
}
Expand Down

0 comments on commit 08f3d23

Please sign in to comment.