---
title: "atomicMemoryFence(ordering:)"
framework: synchronization
role: symbol
role_heading: Function
path: "synchronization/atomicmemoryfence(ordering:)"
---

# atomicMemoryFence(ordering:)

Establishes a memory ordering without associating it with a particular atomic operation.

## Declaration

```swift
func atomicMemoryFence(ordering: AtomicUpdateOrdering)
```

## Discussion

Discussion A relaxed fence has no effect. An acquiring fence ties to any preceding atomic operation that reads a value, and synchronizes with any releasing operation whose value was read. A releasing fence ties to any subsequent atomic operation that modifies a value, and synchronizes with any acquiring operation that reads the result. An acquiring and releasing fence is a combination of an acquiring and a releasing fence. A sequentially consistent fence behaves like an acquiring and releasing fence, and ensures that the fence itself is part of the single, total ordering for all sequentially consistent operations. This operation corresponds to std::atomic_thread_fence in C++. Be aware that Thread Sanitizer does not support fences and may report false-positive races for data protected by a fence.

## See Also

### Memory Ordering Semantics

- [AtomicLoadOrdering](synchronization/atomicloadordering.md)
- [AtomicStoreOrdering](synchronization/atomicstoreordering.md)
- [AtomicUpdateOrdering](synchronization/atomicupdateordering.md)
