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

[SR-7317] libdispatch: dispatch_source_set_*_handler_f have no context parameter #657

Closed
swift-ci opened this issue Mar 31, 2018 · 1 comment

Comments

@swift-ci
Copy link

Previous ID SR-7317
Radar None
Original Reporter moshe (JIRA User)
Type Improvement
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Improvement
Assignee None
Priority Medium

md5: 32351524be15feca9ce95385a306d6cb

Issue Description:

I am evaluating libdispatch for a cross platform C project. I found a bug ( SR-7316 ) that is also related to dispatch sources. Dispatch sources seem hard to use without blocks, because I can not find a way to pass context to the handlers. This also goes against the api design advice in the documentation. (See https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/dispatch_api.3.html )

I can think of only 2 ways to circumvent this problem:

  1. Using dispatch_get_current_queue and doing a lookup to find the context dependent data.

  2. Using some form of dynamic function creation to create a new function depending on the context.

Both seem to have serious problems. The first is deprecated, and the second is hardly a portable solution.

Did I miss anything or is there a pressing reason that dispatch_source_set_*_handler_f do not have a context parameter? I suspect that changing the function signatures is a breaking change that may not be possible, but is there any improvement that can be made to libdispatch to alleviate this problem?

@swift-ci
Copy link
Author

Comment by Pierre Habouzit (JIRA)

Yes, you're missing dispatch_set_context() which is the context passed to the handler as per documentation.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant