From f0631f55b72013c5ff3991ceb408a95858a8a1f2 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 21 Nov 2024 23:13:56 +0100 Subject: [PATCH] Using now a fixed size thread pool as otherwise as many threads get created as there are messages in the inbox which can be really a lot --- .../src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt index 22cbe45..e983699 100644 --- a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt +++ b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt @@ -17,6 +17,7 @@ import java.io.File import java.time.Instant import java.util.* import java.util.concurrent.Executors +import kotlin.math.max class MailReader( private val eInvoiceReader: EInvoiceReader = EInvoiceReader() @@ -28,7 +29,7 @@ class MailReader( ) - private val mailDispatcher = Executors.newCachedThreadPool().asCoroutineDispatcher() + private val mailDispatcher = Executors.newFixedThreadPool(max(24, Runtime.getRuntime().availableProcessors() * 4)).asCoroutineDispatcher() private val log by logger()