[Pitch] Unsafe Assume on MainActor

We've discussed this API a bit more with @kavon and others in the Swift team and we'll need to think a bit more about the implementation details, but we all agree it is a valuable thing to offer.

Circling back to this piece:

now that [Pitch] Custom Actor Executors is pitched, I can confirm that the above can actually be correct, thus a bit more thought needs to be given about what we want to assert on and how.

And it should also be noted that "are we on the main thread" is an incorrect check to perform when checking for "are we on the main actor" because in Dispatch "main queue" does not necessarily have to mean "main thread", and because of upcoming MainActor executor customization, we cannot make other assumptions about what "main actor" runs on, other than comparing executor references.

I'll think more about the semantics we're able to offer and follow up here soon enough.

3 Likes