Skip to content

Commit 5b79ddf

Browse files
Suppress sendability warnings on single-threaded platform
1 parent e2f569a commit 5b79ddf

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Sources/JavaScriptKit/ThreadLocal.swift

+8-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ final class ThreadLocal<Value>: Sendable {
7878
}
7979
#else
8080
// Fallback implementation for platforms that don't support pthread
81-
#if compiler(>=5.10)
82-
nonisolated(unsafe) var wrappedValue: Value?
83-
#else
84-
var wrappedValue: Value?
85-
#endif
81+
private class SendableBox: @unchecked Sendable {
82+
var value: Value? = nil
83+
}
84+
private let _storage = SendableBox()
85+
var wrappedValue: Value? {
86+
get { _storage.value }
87+
set { _storage.value = newValue }
88+
}
8689

8790
init() where Value: AnyObject {
8891
wrappedValue = nil

0 commit comments

Comments
 (0)