Skip to content

Commit 5896c79

Browse files
kateinoigakukunAnka
authored and
Anka
committed
[Synchronization] Skip atomic operations in single-threaded mode on WebAssembly
Use of atomics instructions requires the support of threads proposal and it's not widely supported yet. So we should enable actual atomic operations only when targeting wasm32-uknown-wasip1-threads.
1 parent d39965a commit 5896c79

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

stdlib/public/Synchronization/Mutex/WasmImpl.swift

+4
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ internal func _swift_stdlib_wake(on: UnsafePointer<UInt32>, count: UInt32) -> UI
2525

2626
extension Atomic where Value == _MutexHandle.State {
2727
internal borrowing func _wait(expected: _MutexHandle.State) {
28+
#if false
2829
_ = _swift_stdlib_wait(
2930
on: .init(_rawAddress),
3031
expected: expected.rawValue,
3132

3233
// A timeout of < 0 means indefinitely.
3334
timeout: -1
3435
)
36+
#endif
3537
}
3638

3739
internal borrowing func _wake() {
40+
#if false
3841
// Only wake up 1 thread
3942
_ = _swift_stdlib_wake(on: .init(_rawAddress), count: 1)
43+
#endif
4044
}
4145
}
4246

0 commit comments

Comments
 (0)