Distinction between `@isolated(any)` and `@_inheritActorContext`

Thanks @hborla and @John_McCall for the clarifications. But I find myself still slightly hung up here.

Task uses both these annotations, and I get it. The task group family addTask method uses only @isolated(any), but does not inherit isolation. I sometimes think of task groups as conceptually similar to:

for _ in count {
  Task {
  }
}

But, groups have totally different semantics because they do not inherit the enclosing scope's isolation like Task does. This actually makes them quite hard to use in some circumstances compared to a collection of Task values.

I'm not (currently anyways :grimacing:) arguing for a change these APIs. But I'm really having hard time understanding why these two concepts a) must be separate and b) should also be so easy for developers to use separately.

Given that @isolated(any) allows the creator of the closure to specify any isolation, it kinda feels like fusing that with @_inheritActorContext would just give it an unsurprising default, one that could still be changed if needed just like you can with Task.

Aside from the obvious impact on task groups, are there any other concrete negative implications I'm not thinking of?

3 Likes