-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
RFC: Send+Sync on metal objects #40
Comments
Proposal
ClarificationAtomicity of properties in ObjC guarantees no visible partial writes. While Apple docs say this is not thread safe, they mean data-races in fact, and it's perfectly thread-safe in Rust terms (of memory safety). |
@gfx-rs/metallists |
Also pinging @SSheldon, the author of |
Sorry, I realized why this isn't going to work 😞 . |
Current approachA bit of context here, that's what we currently have for ObjC bindings of Metal:
AnalysisThe main problem for getting any sort of type assistance here is that So here comes the main idea and restriction: let's enforce a guarantee that there is a single Rust object backing a single ObjC object. On Rust side, there is no point to mess with ObjC reference counters. Instead, we can use the regular Unresolved ProblemsAny methods that return new objects to use ( What's not clear, however, is what should be done about getters that return existing objects. e.g. let obj1 = msg_send![parent.get_some_object];
let obj2 = msg_send![parent.get_some_object]; |
An important missing piece of this puzzle is to how we can uniquely track ObjC objects, and @jrmuizel suggested to put the locking internals into the associated data for fast lookups (by our wrappers around ObjC objects, e.g. |
Having objects be uniquely owned by a I like the idea of using associated types, that could make it a lot easier to verify that the uniqueness isn't being violated and could make this all much more doable. |
Given that all the interaction is done via message sending, I don't see why Send+Sync wouldn't be the case?
The text was updated successfully, but these errors were encountered: