-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impl Send+Sync for CFRunLoopTimer, CFRunLoopSource, CFRunLoopObserver #649
base: main
Are you sure you want to change the base?
Conversation
7081449
to
700ea22
Compare
I didn't see a clear reference in the Apple docs about the thread safety of these APIs, apart from that you can register them in a single runloop but not multiple. @madsmtm What do you think of this? It looks like you looked into it some before in the issue that you linked. |
I don't dare say anything about the others, though I will reference this piece of documentation and that CoreFoundation is open source, then you have the same to work with as I do ;). |
Though actually, all of these carry callbacks that the user sets, and those callbacks may not be |
@kevinmehall What is your goal with this change? (I am away from home all day today running errands) |
In nusb, I'm launching a dedicated background thread for a https://github.com/kevinmehall/nusb/blob/main/src/platform/macos_iokit/events.rs I ended up doing this by making newtype wrappers around these types that I could put Send + Sync impls on. Like winit, I actually also only need CFRunLoopSource; the others were included in this PR just because they seemed to have the same properties. Good point on the callbacks -- Looking at the safe functions in this crate that accept callbacks that end up in these types ( I'm fine with needing to write Also, I think making CFRunLoop itself Send+Sync in #610, and the existence of |
Good points overall! Perhaps a solution would be to make This way, e.g. |
Following #610, the same reasoning from #550 applies to the remaining CFRunLoop types.