Skip to content

Commit 84730a4

Browse files
committed
Integrate dispatch2 from https://github.com/marysaka/dispatch2
Part of #77.
2 parents 0bdb036 + 44035e8 commit 84730a4

File tree

10 files changed

+1597
-0
lines changed

10 files changed

+1597
-0
lines changed

crates/dispatch2/Cargo.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "dispatch2"
3+
version = "0.1.0"
4+
authors = ["Mary <[email protected]>"]
5+
license = "Apache-2.0 OR MIT"
6+
repository = "https://www.github.com/marysaka/dispatch2.git"
7+
homepage = "https://www.github.com/marysaka/dispatch2"
8+
description = "Bindings and wrappers for the Grand Central Dispatch (GCD)"
9+
keywords = ["gcd", "macOS", "iOS", "watchOS", "ipadOS"]
10+
categories = ["api-bindings", "development-tools::ffi", "os::macos-apis"]
11+
edition = "2021"
12+
13+
exclude = [
14+
".github"
15+
]
16+
17+
[dependencies]
18+
libc = "0.2"

crates/dispatch2/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# dispatch2
2+
3+
Allows interaction with the [Apple Dispatch](https://developer.apple.com/documentation/dispatch) library in a safe and unsafe way.
4+
5+
## Usage
6+
7+
To use `dispatch2`, add this to your `Cargo.toml`:
8+
9+
```toml
10+
[dependencies]
11+
dispatch2 = "0.1.0"
12+
```
13+
14+
## Example
15+
16+
```rust
17+
use dispatch2::{Queue, QueueAttribute};
18+
19+
fn main() {
20+
let queue = Queue::new("example_queue", QueueAttribute::Serial);
21+
queue.exec_async(|| println!("Hello"));
22+
queue.exec_sync(|| println!("World"));
23+
}
24+
```
25+
26+
## License
27+
28+
dispatch2 is distributed under the terms of either the MIT license or the Apache
29+
License (Version 2.0), at the user's choice.
30+
31+
See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT).

crates/dispatch2/TODO.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# TODO
2+
3+
- Fully document all ffi APIs
4+
- CI test on macOS
5+
- CI test on Linux using https://github.com/apple/swift-corelibs-libdispatch
6+
- CI test on Windows using https://github.com/apple/swift-corelibs-libdispatch
7+
- Safe wrapper for ``dispatch_source_*`` + ``set_target_queue/activate/suspend/resume`` for it
8+
- Safe wrapper for ``dispatch_data_*``
9+
- Safe wrapper for ``dispatch_once_f`` (is that relevent?)
10+
- Safe wrapper for ``dispatch_get_context/dispatch_set_context`` (quite impossible without big overhead => wrap dispatch object destructor to release the boxed value)
11+
- All blocks related bindings and ``dispatch_block_*`` functions with compat with ``block2`` on Apple platforms.
12+
- Integrate conversion from SystemTime to dispatch_time_t via dispatch_walltime and safe APIs using that.

0 commit comments

Comments
 (0)