perf(protocol): enable virtual threads for ccsp server and network io
This commit is contained in:
+3
-5
@@ -55,6 +55,7 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@@ -120,11 +121,8 @@ public class CcspServer {
|
|||||||
InetSocketAddress address = new InetSocketAddress(BIND_HOST, port);
|
InetSocketAddress address = new InetSocketAddress(BIND_HOST, port);
|
||||||
httpServer = HttpServer.create(address, 50);
|
httpServer = HttpServer.create(address, 50);
|
||||||
|
|
||||||
executor = Executors.newFixedThreadPool(8, r -> {
|
ThreadFactory virtualThreadFactory = Thread.ofVirtual().name("ccsp-virtual-worker-", 0).factory();
|
||||||
Thread t = new Thread(r, "ccsp-http-worker");
|
executor = Executors.newThreadPerTaskExecutor(virtualThreadFactory);
|
||||||
t.setDaemon(true);
|
|
||||||
return t;
|
|
||||||
});
|
|
||||||
httpServer.setExecutor(executor);
|
httpServer.setExecutor(executor);
|
||||||
|
|
||||||
// Registra endpoints do protocolo CCSP/1
|
// Registra endpoints do protocolo CCSP/1
|
||||||
|
|||||||
Reference in New Issue
Block a user