Adopt transferring for Mutex init

This commit is contained in:
Alejandro Alonso
2024-03-19 11:12:43 -07:00
parent ba1787c1d5
commit 97072e5b79
2 changed files with 3 additions and 2 deletions

View File

@@ -75,6 +75,7 @@ set(SWIFT_SYNCHRNOIZATION_SWIFT_FLAGS
"-enable-builtin-module" "-enable-builtin-module"
"-enable-experimental-feature" "RawLayout" "-enable-experimental-feature" "RawLayout"
"-enable-experimental-feature" "StaticExclusiveOnly" "-enable-experimental-feature" "StaticExclusiveOnly"
"-enable-experimental-feature" "TransferringArgsAndResults"
) )
add_swift_target_library(swiftSynchronization ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB add_swift_target_library(swiftSynchronization ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB

View File

@@ -47,7 +47,7 @@ public struct Mutex<Value: ~Copyable>: ~Copyable {
@available(SwiftStdlib 6.0, *) @available(SwiftStdlib 6.0, *)
@_alwaysEmitIntoClient @_alwaysEmitIntoClient
@_transparent @_transparent
public init(_ initialValue: consuming Value) { public init(_ initialValue: transferring consuming Value) {
value = _Cell(initialValue) value = _Cell(initialValue)
} }
} }
@@ -120,7 +120,7 @@ extension Mutex where Value: ~Copyable {
/// } /// }
/// return try body(&value) /// return try body(&value)
/// ///
/// - Note: This version of `withLock` is unchecked because it does /// - Note: This version of `tryWithLock` is unchecked because it does
/// not enforce any sendability guarantees. /// not enforce any sendability guarantees.
/// ///
/// - Warning: Recursive calls to `tryWithLockUnchecked` within the /// - Warning: Recursive calls to `tryWithLockUnchecked` within the