From a207fd1f637c87c7a0faec9c3e2e7c24256ff7c1 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Wed, 27 Nov 2024 09:43:29 -0600 Subject: [PATCH] Fix --- Sources/PerceptionCore/Internal/ThreadLocal.swift | 2 +- .../Internal/{UncheckedSendable.swift => Unchecked.swift} | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) rename Sources/PerceptionCore/Internal/{UncheckedSendable.swift => Unchecked.swift} (50%) diff --git a/Sources/PerceptionCore/Internal/ThreadLocal.swift b/Sources/PerceptionCore/Internal/ThreadLocal.swift index 57a400a..c1af3ca 100644 --- a/Sources/PerceptionCore/Internal/ThreadLocal.swift +++ b/Sources/PerceptionCore/Internal/ThreadLocal.swift @@ -18,7 +18,7 @@ struct _ThreadLocal { get { _value.value } set { _value.value = newValue } } - private let _value = UncheckedSendable(nil) + private static let _value = UncheckedBox(nil) #else static var value: UnsafeMutableRawPointer? { get { Thread.current.threadDictionary[Key()] as! UnsafeMutableRawPointer? } diff --git a/Sources/PerceptionCore/Internal/UncheckedSendable.swift b/Sources/PerceptionCore/Internal/Unchecked.swift similarity index 50% rename from Sources/PerceptionCore/Internal/UncheckedSendable.swift rename to Sources/PerceptionCore/Internal/Unchecked.swift index 712c62f..ea7e8e9 100644 --- a/Sources/PerceptionCore/Internal/UncheckedSendable.swift +++ b/Sources/PerceptionCore/Internal/Unchecked.swift @@ -1,3 +1,9 @@ +@usableFromInline final class UncheckedBox: @unchecked Sendable { + @usableFromInline var value: Value + @usableFromInline init(_ value: Value) { + self.value = value + } +} @usableFromInline struct UncheckedSendable: @unchecked Sendable { @usableFromInline let value: Value @usableFromInline init(_ value: Value) {