If Swift 6 is enabled but no actors are used, is there any runtime enforcement if a data race occurs? Or any other concurrency situation?
While a few things require runtime enforcement, generally the goal of the concurrency model is to enforce correctness at compile time. Even if actors are not used, there are some language features that involve concurrency, for example this diagnoses a data race error:
class C {
func f() {}
}
func f() {
let c = C()
Task {
c.f()
}
print(c)
}
Thanks. I suppose I could broaden my question to not using any new SC features like tasks., async/await, and actors. Assuming just sendable changes are made, is there any runtime enforcement related there? I’m pretty confident it’s no but just want to understand any possible edge cases.
Not sure if this is the kind of answer you are looking for but swift_beginAccess
and swift_endAccess
can slow down performance if you are accessing data from a class
reference. Those can be compiled out if you want to ship YOLO FIDLAR… but generally AFAIK the advice is to leave them activated.