system-configuration-rs
system-configuration-rs copied to clipboard
Requires Send + Sync + 'static in dynamic store callout
Closes #51
I think to the least, Send + 'static is required. But it also depends on whether the callback might be invoked concurrently, which I think is possible, since in Concurrent style dispatch queue that can happen. So I'd say it's necessary to require the callback to also be Sync.
Interesting. Good find! Do you know of any Apple documentation talking about how the callback can be called?
I have not touched this code in a long time, and have not lookup up the details here now. But the CFRunLoopSource you can obtain to run this object is !Send, so you can't send it to a different thread to schedule it. Is it still possible to schedule the store to dispatch callbacks from other threads? :thinking:
I'm not that familiar with macOS. And I agree that it looks to me that running it using cf run loop is Okay, as long as CFRunLoopSource is !Send.
But, it's also possible to be dispatched using SCDynamicStoreSetDispatchQueue, and when using a dispatch queue, callbacks can be called concurrently. There is an article on this: Concurrent vs Serial DispatchQueue.