# \[Pitch #2\] Async/await

**URL:** <https://forums.swift.org/t/pitch-2-async-await/42420>\
**Category:** Pitches\
**Created:** [December 2, 2020, 12:04am UTC](https://forums.swift.org/t/pitch-2-async-await/42420 "2020-12-02T00:04:54Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [December 2, 2020, 8:40pm UTC](https://forums.swift.org/t/pitch-2-async-await/42420/18 "2020-12-02T20:40:04Z")

</div>

> [@Chris\_Lattner3](#):
>
> I guess I still don't really understand the difference here between async actor methods and normal async methods for the purpose of `inout` handling. Both are interruptable, and both have the same issue with local variable and closures.

There isn't a difference between async actor methods and normal async methods. Both can have `inout` parameters. The restrictions we need are on which arguments you can provide, to ensure that you have exclusive access to the argument to the `inout` even across a suspension. The [actor proposal](https://github.com/DougGregor/swift-evolution/blob/actors/proposals/nnnn-actors.md#inout-parameters) states the restriction for actor-isolated instance members:

> Actor-isolated stored properties can be passed into synchronous functions via inout parameters, but it is ill-formed to pass them to asynchronous functions via inout parameters. For example:

```swift
func modifiesSynchronously(_: inout Double) { }
func modifiesAsynchronously(_: inout Double) async { }

extension BankAccount {
  func wildcardBalance() async {
    modifiesSynchronously(&balance) // okay
    await modifiesAsynchronously(&balance) // error: actor-isolated property 'balance' cannot be passed 'inout' to an asynchronous function
  }
}  

```

> This restriction prevents exclusivity violations where the modification of the actor-isolated balance is initiated by passing it as inout to a call that is then suspended, and another task executed on the same actor then fails with an exclusivity violation in trying to access balance itself.

It doesn't matter whether `modifiesAsynchronously` is on an actor or not; you still can't pass `&self.balance` to it.

However, it would be fine to pass `&myLocalVariable` to it so long as we've already ensured that `myLocalVariable` doesn't have captures that can run concurrently. That's partially implemented as a warning in the experimental concurrency mode, and I promised (somewhere these threads) to bring that into one of the proposals... but haven't done so yet.

Doug

---

_[View the full topic](https://forums.swift.org/t/pitch-2-async-await/42420)._
