IJPL-161551 IJ-CR-144280 Avoid excessive memory barrier in BasicFileAttributesHolder2.Impl

GitOrigin-RevId: c92e73a2acd82f077fbf733d789bbce5ac16a878
This commit is contained in:
Vladimir Lagunov
2024-09-10 16:01:01 +02:00
committed by intellij-monorepo-bot
parent 2a88042525
commit a9e495c158
3 changed files with 8 additions and 17 deletions

View File

@@ -39,7 +39,11 @@ public interface BasicFileAttributesHolder2 extends BasicFileAttributesHolder {
* however strange the original works, this implementation should work the same.
* </p>
*/
protected volatile @NotNull WeakReference<@Nullable BasicFileAttributes> myCachedAttributes = new WeakReference<>(null);
protected final @NotNull WeakReference<@Nullable BasicFileAttributes> myCachedAttributes;
protected Impl(@Nullable BasicFileAttributes attributes) {
myCachedAttributes = new WeakReference<>(attributes);
}
@Override
public BasicFileAttributes get() {

View File

@@ -21,17 +21,13 @@ class IjentNioPath internal constructor(
val ijentPath: IjentPath,
internal val nioFs: IjentNioFileSystem,
cachedAttributes: BasicFileAttributes?,
) : Path, BasicFileAttributesHolder2.Impl() {
) : Path, BasicFileAttributesHolder2.Impl(cachedAttributes) {
private val isWindows
get() = when (nioFs.ijentFs) {
is IjentFileSystemPosixApi -> false
is IjentFileSystemWindowsApi -> true
}
init {
myCachedAttributes = WeakReference(cachedAttributes)
}
override fun getFileSystem(): IjentNioFileSystem = nioFs
override fun isAbsolute(): Boolean =

View File

@@ -2,23 +2,14 @@
package com.intellij.execution.wsl.ijent.nio
import com.intellij.platform.core.nio.fs.BasicFileAttributesHolder2
import java.lang.ref.WeakReference
import java.net.URI
import java.nio.file.LinkOption
import java.nio.file.Path
import java.nio.file.WatchEvent
import java.nio.file.WatchKey
import java.nio.file.WatchService
import java.nio.file.*
class IjentWslNioPath(
private val fileSystem: IjentWslNioFileSystem,
val delegate: Path,
cachedAttributes: IjentNioPosixFileAttributesWithDosAdapter?,
) : Path, BasicFileAttributesHolder2.Impl() {
init {
myCachedAttributes = WeakReference(cachedAttributes)
}
) : Path, BasicFileAttributesHolder2.Impl(cachedAttributes) {
override fun getFileSystem(): IjentWslNioFileSystem = fileSystem
override fun isAbsolute(): Boolean = delegate.isAbsolute