Skip to content

Commit

Permalink
Fix a thread leak that prevented the compilation from finishing when …
Browse files Browse the repository at this point in the history
…using kotlin.native.disableCompilerDaemon.
  • Loading branch information
FilipDolnik committed May 16, 2024
1 parent f32a7bd commit ebe197b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import kotlinx.serialization.Serializable
import java.util.concurrent.Executors
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
import kotlin.coroutines.CoroutineContext
import kotlin.time.Duration
import kotlin.time.DurationUnit
Expand All @@ -22,7 +24,9 @@ object SkiePerformanceAnalytics {
private val rootConfiguration: RootConfiguration,
) : AnalyticsProducer {

private val dispatcher: CoroutineContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
private val threadExecutor = ThreadPoolExecutor(0, 1, 1, TimeUnit.MINUTES, LinkedBlockingQueue())

private val dispatcher: CoroutineContext = threadExecutor.asCoroutineDispatcher()

override val name: String = "skie-performance"

Expand All @@ -39,6 +43,8 @@ object SkiePerformanceAnalytics {

collected = true

threadExecutor.setKeepAliveTime(1, TimeUnit.SECONDS)

entries.toPrettyJson()
}

Expand Down

0 comments on commit ebe197b

Please sign in to comment.