From d6a64f2eeb23e167e9d24eacbbfe3b88d3bb4c2f Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 4 Jan 2019 17:03:35 +0100 Subject: [PATCH] save storage files in pooled thread - part1: move project name saving from doSave to beforeSaveComponents because it is more logical place No need to apply planned optimization for project name saving because it is changed very rarely - better to make code more simple. Later, when feature will be fully implemented, maybe it will be also optimized if need --- .../src/ComponentStoreWithExtraComponents.kt | 4 ++-- platform/configuration-store-impl/src/ProjectStoreImpl.kt | 6 +++++- .../configuration-store-impl/src/StateStorageManagerImpl.kt | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt b/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt index 68e0b892d72a..1bd4ab775292 100644 --- a/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt +++ b/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.configurationStore import com.intellij.configurationStore.schemeManager.SchemeManagerFactoryBase @@ -16,7 +16,7 @@ abstract class ComponentStoreWithExtraComponents : ComponentStoreImpl() { super.initComponent(component, isService) } - final override fun beforeSaveComponents(errors: MutableList) { + override fun beforeSaveComponents(errors: MutableList) { // component state uses scheme manager in an ipr project, so, we must save it before val isIprProject = project?.let { !it.isDirectoryBased } ?: false if (isIprProject) { diff --git a/platform/configuration-store-impl/src/ProjectStoreImpl.kt b/platform/configuration-store-impl/src/ProjectStoreImpl.kt index aff00aba822a..98165720aea0 100644 --- a/platform/configuration-store-impl/src/ProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/ProjectStoreImpl.kt @@ -322,7 +322,7 @@ private open class ProjectStoreImpl(project: Project, private val pathMacroManag } } - override fun doSave(saveSession: SaveExecutor, readonlyFiles: MutableList, errors: MutableList) { + final override fun beforeSaveComponents(errors: MutableList) { try { saveProjectName() } @@ -330,6 +330,10 @@ private open class ProjectStoreImpl(project: Project, private val pathMacroManag LOG.error("Unable to store project name", e) } + super.beforeSaveComponents(errors) + } + + override fun doSave(saveSession: SaveExecutor, readonlyFiles: MutableList, errors: MutableList) { beforeSave(readonlyFiles) super.doSave(saveSession, readonlyFiles, errors) diff --git a/platform/configuration-store-impl/src/StateStorageManagerImpl.kt b/platform/configuration-store-impl/src/StateStorageManagerImpl.kt index ad3aa400e43f..f35fb7dfe09d 100644 --- a/platform/configuration-store-impl/src/StateStorageManagerImpl.kt +++ b/platform/configuration-store-impl/src/StateStorageManagerImpl.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.configurationStore import com.intellij.openapi.Disposable @@ -328,6 +328,7 @@ open class StateStorageManagerImpl(private val rootTagName: String, open val isExternalSystemStorageEnabled: Boolean get() = false + // function must be pure and do not use anything outside of passed arguments protected open fun beforeElementSaved(elements: MutableList, rootAttributes: MutableMap) { }