forked from rnorth/dropwizard-loom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFiberBackedThreadPool.java
More file actions
36 lines (28 loc) · 903 Bytes
/
FiberBackedThreadPool.java
File metadata and controls
36 lines (28 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package example;
import org.eclipse.jetty.util.thread.ThreadPool;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class FiberBackedThreadPool implements ThreadPool {
ExecutorService executorService = Executors.newWorkStealingPool(10); // TODO tune for the minimum number of threads we need
@Override
public void execute(Runnable command) {
FiberScope.background().schedule(executorService, command);
}
@Override
public void join() throws InterruptedException {
executorService.awaitTermination(1, TimeUnit.DAYS);
}
@Override
public int getThreads() {
return 0; // TODO: change?
}
@Override
public int getIdleThreads() {
return Integer.MAX_VALUE;
}
@Override
public boolean isLowOnThreads() {
return false;
}
}