Skip to content

Commit af33a1e

Browse files
Define primitive lock type for WASI
WASI without `_runtime(multithreaded)` does not support locks. This commit defines the underlying lock type as `Void` in this case. `ManagedBuffer<T, Void>` just wastes a word of storage space, so it's not optimal but it's good at code sharing across platforms.
1 parent 8ab148a commit af33a1e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Sources/Testing/Support/Locked.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct Locked<T>: RawRepresentable, Sendable where T: Sendable {
4242
private typealias _Lock = SRWLOCK
4343
#elseif os(WASI)
4444
// No locks on WASI without multithreaded runtime.
45+
private typealias _Lock = Void
4546
#else
4647
#warning("Platform-specific implementation missing: locking unavailable")
4748
private typealias _Lock = Void

0 commit comments

Comments
 (0)