---
title: "withLock(flags:_:)"
framework: os
role: symbol
role_heading: Instance Method
path: "os/osallocatedunfairlock/withlock(flags:_:)-1ub4c"
---

# withLock(flags:_:)

## Declaration

```swift
func withLock<R>(flags: OSAllocatedUnfairLockFlags, _ body: @Sendable (inout State) throws -> R) rethrows -> R where R : Sendable
```
