Define custom task pool instead of default phobos.
Build and Test Module / build-and-test (push) Successful in 12s Details
Build and Test Module / integration-tests (push) Successful in 18s Details

This commit is contained in:
Andrew Lalis 2025-08-09 11:20:02 -04:00
parent 5e79fba1b4
commit 01d48e9537
1 changed files with 5 additions and 1 deletions

View File

@ -13,8 +13,11 @@ import slf4d;
* and submitted to the standard task pool.
*/
class TaskPoolHttp1Transport : Http1Transport {
private TaskPool httpTaskPool;
this(HttpRequestHandler requestHandler, ushort port = 8080) {
super(requestHandler, port);
this.httpTaskPool = new TaskPool(5);
}
override void runServer() {
@ -31,13 +34,14 @@ class TaskPoolHttp1Transport : Http1Transport {
Socket clientSocket = serverSocket.accept();
trace("Accepted a new socket.");
auto t = task!handleClient(clientSocket, requestHandler);
taskPool().put(t);
this.httpTaskPool.put(t);
trace("Added handleClient() task to the task pool.");
} catch (SocketAcceptException e) {
warn("Failed to accept socket connection.", e);
}
}
serverSocket.close();
this.httpTaskPool.stop();
}
override void stop() {