Skip to content
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

Requires Send + Sync + 'static in dynamic store callout #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Congyuwang
Copy link

@Congyuwang Congyuwang commented Jul 22, 2024

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.

This change is Reviewable

@faern
Copy link
Member

faern commented Aug 22, 2024

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? 🤔

@Congyuwang
Copy link
Author

Congyuwang commented Aug 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Require 'static + Send + Sync for proxy callback info?
2 participants