Skip to content

Commit

Permalink
Integrate dispatch2 from https://github.com/marysaka/dispatch2
Browse files Browse the repository at this point in the history
Part of #77.
  • Loading branch information
madsmtm committed Dec 17, 2024
2 parents 0bdb036 + 44035e8 commit 84730a4
Show file tree
Hide file tree
Showing 10 changed files with 1,597 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/dispatch2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "dispatch2"
version = "0.1.0"
authors = ["Mary <[email protected]>"]
license = "Apache-2.0 OR MIT"
repository = "https://www.github.com/marysaka/dispatch2.git"
homepage = "https://www.github.com/marysaka/dispatch2"
description = "Bindings and wrappers for the Grand Central Dispatch (GCD)"
keywords = ["gcd", "macOS", "iOS", "watchOS", "ipadOS"]
categories = ["api-bindings", "development-tools::ffi", "os::macos-apis"]
edition = "2021"

exclude = [
".github"
]

[dependencies]
libc = "0.2"
31 changes: 31 additions & 0 deletions crates/dispatch2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# dispatch2

Allows interaction with the [Apple Dispatch](https://developer.apple.com/documentation/dispatch) library in a safe and unsafe way.

## Usage

To use `dispatch2`, add this to your `Cargo.toml`:

```toml
[dependencies]
dispatch2 = "0.1.0"
```

## Example

```rust
use dispatch2::{Queue, QueueAttribute};

fn main() {
let queue = Queue::new("example_queue", QueueAttribute::Serial);
queue.exec_async(|| println!("Hello"));
queue.exec_sync(|| println!("World"));
}
```

## License

dispatch2 is distributed under the terms of either the MIT license or the Apache
License (Version 2.0), at the user's choice.

See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT).
12 changes: 12 additions & 0 deletions crates/dispatch2/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# TODO

- Fully document all ffi APIs
- CI test on macOS
- CI test on Linux using https://github.com/apple/swift-corelibs-libdispatch
- CI test on Windows using https://github.com/apple/swift-corelibs-libdispatch
- Safe wrapper for ``dispatch_source_*`` + ``set_target_queue/activate/suspend/resume`` for it
- Safe wrapper for ``dispatch_data_*``
- Safe wrapper for ``dispatch_once_f`` (is that relevent?)
- Safe wrapper for ``dispatch_get_context/dispatch_set_context`` (quite impossible without big overhead => wrap dispatch object destructor to release the boxed value)
- All blocks related bindings and ``dispatch_block_*`` functions with compat with ``block2`` on Apple platforms.
- Integrate conversion from SystemTime to dispatch_time_t via dispatch_walltime and safe APIs using that.
Loading

0 comments on commit 84730a4

Please sign in to comment.