---
title: "exchange(_:ordering:)"
framework: synchronization
role: symbol
role_heading: Instance Method
path: "synchronization/atomic/exchange(_:ordering:)-8ip0d"
---

# exchange(_:ordering:)

Atomically sets the current value to desired and returns the original value, applying the specified memory ordering.

## Declaration

```swift
func exchange(_ desired: consuming Value, ordering: AtomicUpdateOrdering) -> Value
```

## Parameters

- `desired`: The desired new value.
- `ordering`: The memory ordering to apply on this operation.

## Return Value

Return Value The original value.
