@Polyphonic
This is a simplified example to be able to ask the question, rather than asking "here's my architecture, is it safe?" My use case is an object that has a public API that includes private(set) properties (where @Published comes in useful), internally the values may be updated from any thread, and Sendable conformance is required because the object is passed to an actor.
Are you implying "this could create incorrect values" or does the unsafe nature of this extend to "this is unsafe and may crash"? I am aiming for correctness, but it would be interesting to know why if this isn't safe and why my naive test doesn't crash. Is there a scenario that can be created where this would crash?
I've seen others using @Published properties with @MainThread, which I would guess makes this safe, but it doesn't fix the correctness side of things. e.g. reading the value, checking the value, then writing the value is not a single atomic operation. For this I think locks/private queues would be suitable, but that's out of scope for this discussion.