mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-23 14:04:16 +00:00
Use virtual threads
This commit is contained in:
parent
32c8d4f801
commit
0bd4d554d8
@ -212,6 +212,17 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "com.sun.crypto.provider.HKDFKeyDerivation$HKDFSHA384",
|
||||||
|
"methods": [
|
||||||
|
{
|
||||||
|
"name": "<init>",
|
||||||
|
"parameterTypes": [
|
||||||
|
"javax.crypto.KDFParameters"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "com.sun.crypto.provider.HmacCore$HmacSHA256",
|
"type": "com.sun.crypto.provider.HmacCore$HmacSHA256",
|
||||||
"methods": [
|
"methods": [
|
||||||
@ -1006,6 +1017,9 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "java.lang.VirtualThread"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "java.lang.annotation.Retention",
|
"type": "java.lang.annotation.Retention",
|
||||||
"methods": [
|
"methods": [
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -20,7 +20,7 @@ public class JobExecutor implements AutoCloseable {
|
|||||||
|
|
||||||
public JobExecutor(final Context context) {
|
public JobExecutor(final Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.executorService = Executors.newCachedThreadPool();
|
this.executorService = Executors.newVirtualThreadPerTaskExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enqueueJob(Job job) {
|
public void enqueueJob(Job job) {
|
||||||
|
|||||||
@ -157,7 +157,7 @@ public class ManagerImpl implements Manager {
|
|||||||
private final SignalDependencies dependencies;
|
private final SignalDependencies dependencies;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
private final ExecutorService executor = Executors.newCachedThreadPool();
|
private final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
|
||||||
|
|
||||||
private Thread receiveThread;
|
private Thread receiveThread;
|
||||||
private boolean isReceivingSynchronous;
|
private boolean isReceivingSynchronous;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class HttpServerHandler implements AutoCloseable {
|
|||||||
logger.debug("Starting HTTP server on {}", address);
|
logger.debug("Starting HTTP server on {}", address);
|
||||||
|
|
||||||
server = HttpServer.create(address, 0);
|
server = HttpServer.create(address, 0);
|
||||||
server.setExecutor(Executors.newCachedThreadPool());
|
server.setExecutor(Executors.newVirtualThreadPerTaskExecutor());
|
||||||
|
|
||||||
server.createContext("/api/v1/rpc", this::handleRpcEndpoint);
|
server.createContext("/api/v1/rpc", this::handleRpcEndpoint);
|
||||||
server.createContext("/api/v1/events", this::handleEventsEndpoint);
|
server.createContext("/api/v1/events", this::handleEventsEndpoint);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class JsonRpcReader {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (final var executor = Executors.newCachedThreadPool()) {
|
try (final var executor = Executors.newVirtualThreadPerTaskExecutor()) {
|
||||||
while (!Thread.interrupted()) {
|
while (!Thread.interrupted()) {
|
||||||
final var input = lineSupplier.get();
|
final var input = lineSupplier.get();
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
@ -91,7 +91,7 @@ public class JsonRpcReader {
|
|||||||
case JsonRpcBatchMessage jsonRpcBatchMessage -> {
|
case JsonRpcBatchMessage jsonRpcBatchMessage -> {
|
||||||
final var messages = jsonRpcBatchMessage.getMessages();
|
final var messages = jsonRpcBatchMessage.getMessages();
|
||||||
final var responseList = new ArrayList<JsonRpcResponse>(messages.size());
|
final var responseList = new ArrayList<JsonRpcResponse>(messages.size());
|
||||||
try (final var executor = Executors.newCachedThreadPool()) {
|
try (final var executor = Executors.newVirtualThreadPerTaskExecutor()) {
|
||||||
final var lock = new ReentrantLock();
|
final var lock = new ReentrantLock();
|
||||||
messages.forEach(jsonNode -> {
|
messages.forEach(jsonNode -> {
|
||||||
final JsonRpcRequest request;
|
final JsonRpcRequest request;
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public class SocketHandler implements AutoCloseable {
|
|||||||
logger.debug("Starting JSON-RPC server on {}", address);
|
logger.debug("Starting JSON-RPC server on {}", address);
|
||||||
|
|
||||||
listenerThread = Thread.ofPlatform().name("daemon-listener").start(() -> {
|
listenerThread = Thread.ofPlatform().name("daemon-listener").start(() -> {
|
||||||
try (final var executor = Executors.newCachedThreadPool()) {
|
try (final var executor = Executors.newVirtualThreadPerTaskExecutor()) {
|
||||||
logger.info("Started JSON-RPC server on {}", address);
|
logger.info("Started JSON-RPC server on {}", address);
|
||||||
while (true) {
|
while (true) {
|
||||||
final var connectionId = threadNumber.getAndIncrement();
|
final var connectionId = threadNumber.getAndIncrement();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user