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

Add Dispatch / libdispatch #77

Open
1 of 17 tasks
madsmtm opened this issue Nov 22, 2021 · 6 comments
Open
1 of 17 tasks

Add Dispatch / libdispatch #77

madsmtm opened this issue Nov 22, 2021 · 6 comments
Labels
A-dispatch2 Affects the `dispatch2` crate enhancement New feature or request

Comments

@madsmtm
Copy link
Owner

madsmtm commented Nov 22, 2021

Reasoning:

  • Better main thread support.
  • objc2 encoding support (allowing use in framework crates).
  • async support?
  • Optimizations (such as the null-ptr optimization, and others).

Desired name: dispatch2, since it fits fairly well with the naming scheme (objc2, block2 and dispatch2 would all be successors to objc, block and dispatch, and would all be libraries internally, as compared to the rest of the crates we expose, which are all frameworks). I've asked for the name here, should remember to not close this issue until that repo is archived too.

Unsure how auto-generated we can feasibly be here? But the library is comparatively small compared to most frameworks, so it's probably possible to generate an initial starting point, and then refine later on.

Upstream dispatch issues:

Upstream dispatch pull requests to integrate:

Integrate ideas from:

Other TODOs:

  • Use in framework crates.
  • Refactor such that we have less ugly types lying around.
@madsmtm madsmtm mentioned this issue Nov 22, 2021
7 tasks
@madsmtm madsmtm changed the title Integrate the dispatch crate? If so, under what name? Integrate the dispatch crate? Nov 22, 2021
@madsmtm madsmtm added the enhancement New feature or request label Nov 22, 2021
@silvanshade
Copy link
Contributor

I think this would be a good idea. Note that the types are needed for a full translation of the BackgroundTasks framework just added. I also find that I am using it quote a lot for working with the WebKit framework through icrate, though it's conceivable that many of those instances would go away if #279 happens.

@pronebird
Copy link

pronebird commented Dec 6, 2024

This would be incredibly useful and with the following pr being merged, it would enable a quite nice interop between ffi/objc/rust.

@madsmtm madsmtm added this to the objc2 v0.6 / frameworks v0.3 milestone Dec 17, 2024
@madsmtm madsmtm changed the title Integrate the dispatch crate? Integrate the dispatch crate Dec 17, 2024
@madsmtm madsmtm changed the title Integrate the dispatch crate Add libdispatch Dec 17, 2024
@madsmtm madsmtm changed the title Add libdispatch Add Dispatch / libdispatch Dec 17, 2024
madsmtm added a commit that referenced this issue Dec 17, 2024
- Add to CI.
- Update to 2021 edition.
- Appease Clippy.
- Support visionOS and watchOS.
- Align Cargo.toml metadata with the rest of the project.
- Fix typos.

Part of #77.
madsmtm added a commit that referenced this issue Dec 17, 2024
- Add to CI.
- Update to 2021 edition.
- Support visionOS and watchOS.
- Align Cargo.toml metadata with the rest of the project.
- Fix typos.
- Appease Clippy.
- Prefer `Box::into_raw` over `Box::leak`.

Part of #77.
@madsmtm madsmtm added the A-dispatch2 Affects the `dispatch2` crate label Dec 17, 2024
madsmtm added a commit that referenced this issue Dec 17, 2024
- Add to CI.
- Update to 2021 edition.
- Support visionOS and watchOS.
- Align Cargo.toml metadata with the rest of the project.
- Fix typos.
- Appease Clippy.
- Prefer `Box::into_raw` over `Box::leak`.
- Consolidate documentation.

Part of #77.
madsmtm added a commit that referenced this issue Dec 17, 2024
- Add to CI.
- Update to 2021 edition.
- Support visionOS and watchOS.
- Align Cargo.toml metadata with the rest of the project.
- Fix typos.
- Appease Clippy.
- Prefer `Box::into_raw` over `Box::leak`.
- Consolidate documentation.

Part of #77.
madsmtm added a commit that referenced this issue Dec 17, 2024
- Add to CI.
- Update to 2021 edition.
- Support visionOS and watchOS.
- Align Cargo.toml metadata with the rest of the project.
- Fix typos.
- Appease Clippy.
- Prefer `Box::into_raw` over `Box::leak`.
- Consolidate documentation.

Part of #77.
@madsmtm
Copy link
Owner Author

madsmtm commented Dec 17, 2024

I have integrated the dispatch2 crate in 84730a4. This issue now tracks the upstream dispatch issues, as well as making sure we grab all relevant functionality from the other GCD crates.

@pronebird
Copy link

pronebird commented Dec 17, 2024

@madsmtm amazing thank you! I am pulling dispatch2 from crates into my project.

@yujonglee
Copy link

Hi @madsmtm, does resolving this issue imply that we will have dispatch_queue_t support in objc2?

@madsmtm
Copy link
Owner Author

madsmtm commented Dec 20, 2024

Yeah, I'm working on figuring out hooking it up to header-translator, but it requires some changes in dispatch2, including making the types ABI-compatible.

Which is currently hard to do, since we have the extra is_activated state. The header says that it's undefined behaviour to call dispatch_set_target_queue after dispatch_activate, so we currently must keep it for soundness, but I suspect the claim to be incorrect, that it isn't language-level UB, just a programmer error.

So I'll investigate further, and try to upstream a documentation update, otherwise we might have to mark some of these functions as unsafe.

madsmtm added a commit that referenced this issue Dec 20, 2024
To:
- Ensure that it's correct and complete.
- Enable better documentation once we translate header comments too.
- Allow better integration with frameworks in the future.

Part of #77.
madsmtm added a commit that referenced this issue Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dispatch2 Affects the `dispatch2` crate enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants