---
title: setBarrier()
framework: metal
role: symbol
role_heading: Instance Method
path: metal/mtlindirectcomputecommand/setbarrier()
---

# setBarrier()

Adds a barrier to ensure that commands executed prior to this command are complete before this command executes.

## Declaration

```swift
func setBarrier()
```

## Discussion

Discussion Set or clear barriers (as needed) before encoding the command.

## See Also

### Synchronizing command execution

- [clearBarrier()](metal/mtlindirectcomputecommand/clearbarrier().md)
