in hot-reload-devtools/src/main/kotlin/org/jetbrains/compose/devtools/shutdown.kt [97:134]
override fun run() {
val startInstant = System.currentTimeMillis()
val shutdownReportWriter = shutdownReportFile?.createParentDirectories()?.bufferedWriter()
shutdownReportWriter?.appendLine("Shutting down (DevTools '${ProcessHandle.current().pid()}')")
shutdownReportWriter?.appendLine("Shutdown actions registered: ${actions.size}")
shutdownReportWriter?.flush()
var totalFailures = 0
var totalSuccess = 0
while (actions.isNotEmpty()) {
val action = actions.poll() ?: continue
val result = Try { action.work() }
if (result.isSuccess()) {
totalSuccess++
}
if (result.isFailure()) {
totalFailures++
logShutdownActionFailure(action, result.exception)
}
}
val endInstant = System.currentTimeMillis()
val duration = (endInstant - startInstant).milliseconds
shutdownReportWriter?.appendLine("Shutdown actions completed: $totalSuccess, failed: $totalFailures")
shutdownReportWriter?.appendLine("Shutdown duration: $duration")
/* Take all undispatched logs and append them to the shutdown logs */
while (true) {
val log = devtoolsLoggingQueue.nextOrNull().leftOrNull() ?: break
shutdownReportWriter?.appendLine(log.displayString(useEffects = false))
}
shutdownReportWriter?.close()
}