Skip to content

Commit 01562bc

Browse files
committed
Relax escaping requirement for closures in Async{Lock|Mutex}
The closures do not actually escape within the method bodies, so drop `@escaping` from the parameters.
1 parent d992a19 commit 01562bc

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

Sources/Containerization/LinuxContainer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ extension LinuxContainer {
922922
agent: agent,
923923
vm: startedState.vm,
924924
logger: self.logger,
925-
onDelete: { [weak self = self] in
925+
onDelete: { [weak self] in
926926
await self?.removeProcess(id: id)
927927
}
928928
)
@@ -959,7 +959,7 @@ extension LinuxContainer {
959959
agent: agent,
960960
vm: state.vm,
961961
logger: self.logger,
962-
onDelete: { [weak self = self] in
962+
onDelete: { [weak self] in
963963
await self?.removeProcess(id: id)
964964
}
965965
)

Sources/ContainerizationExtras/AsyncLock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public actor AsyncLock {
3434
}
3535

3636
/// withLock provides a scoped locking API to run a function while holding the lock.
37-
public func withLock<T: Sendable>(logMetadata: Logger.Metadata? = nil, _ body: @Sendable @escaping (Context) async throws -> T) async rethrows -> T {
37+
public func withLock<T: Sendable>(logMetadata: Logger.Metadata? = nil, _ body: @Sendable (Context) async throws -> T) async rethrows -> T {
3838
log?.debug("acquiring lock", metadata: logMetadata)
3939
while self.busy {
4040
await withCheckedContinuation { cc in

Sources/ContainerizationExtras/AsyncMutex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public actor AsyncMutex<T: Sendable> {
3636

3737
/// withLock provides a scoped locking API to run a function while holding the lock.
3838
/// The protected value is passed to the closure for safe access.
39-
public func withLock<R: Sendable>(_ body: @Sendable @escaping (inout T) async throws -> R) async rethrows -> R {
39+
public func withLock<R: Sendable>(_ body: @Sendable (inout T) async throws -> R) async rethrows -> R {
4040
while self.busy {
4141
await withCheckedContinuation { cc in
4242
self.queue.append(cc)

0 commit comments

Comments
 (0)