# Cannot understand the nature of data race warnings in Swift 5.10

**URL:** <https://forums.swift.org/t/cannot-understand-the-nature-of-data-race-warnings-in-swift-5-10/70472>\
**Category:** Using Swift\
**Tags:** concurrency\
**Created:** [March 6, 2024, 5:22pm UTC](https://forums.swift.org/t/cannot-understand-the-nature-of-data-race-warnings-in-swift-5-10/70472 "2024-03-06T17:22:53Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![hborla](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hborla/32/27563_2.png) [@hborla](https://forums.swift.org/u/hborla)\
**Post date:** [March 7, 2024, 4:50pm UTC](https://forums.swift.org/t/cannot-understand-the-nature-of-data-race-warnings-in-swift-5-10/70472/6 "2024-03-07T16:50:11Z")

</div>

> [@vns](#):
>
> So in the way I am using it in this particular case, this isolation of `B` on `A` is what I need. And if I do not want to make it isolated on the actor, I need it to be sendable, since it is possible to create two tasks that call `A.prepare` and therefore access `B` which is not safe to access in that way, is that correct?

Yes, that's right. the calls to `A().prepare()` on the same actor value can't be run in parallel, but the code in your second call to `A().prepare()` can run concurrently with the first call to `b.prepare()` if `b` is not isolated to the actor that stores it. The behavior of actors where they are freed up to do other work while waiting on an async function to finish is called [actor re-entrancy](https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md#actor-reentrancy), and it's what allows Swift concurrency to always make forward progress.

> [@vns](#):
>
> To be precise, I can specify an actor isolation parameter here as well, but this will require:
> 
> 1. Make all such methods on the `List` class(es) to accept actor as parameter.
> 2. Until Swift 6, ensure that all calls receive correct actor when being called.
> 
> The second point is reasonable, since concurrency is not complete so far. But for the first I do not see a solution (maybe I am missing something, of course).
> 
> Being more explicit on execution context is a good thing, so I would like to specify it explicitly per use case, like...
> 
> ```swift
> struct CommandsImpl: Commands {
> @isolated(MainActor.shared)
> private let list = List()
>     
> func load() {
> handler.task {
> await list.load() // now this will be isolated on main actor
> }
> }
> }
> 
> ```
> 
> ...to make all the calls to the list isolated on the main actor. This attribute on a property, probably, has little sense matching to the effect, but so far I have no better expression to that.

Right, isolated parameters are the only way to accomplish the effect you're describing right now. There are some other ideas for isolating an entire non-`Sendable` type to an actor value being discussed over in [Isolation Assumptions - #56 by Nickolas\_Pohilets](https://forums.swift.org/t/isolation-assumptions/69514/56)

---

_[View the full topic](https://forums.swift.org/t/cannot-understand-the-nature-of-data-race-warnings-in-swift-5-10/70472)._
