Skip to content

Commit 3cf8c98

Browse files
committed
Added Source example.
1 parent 993ce4c commit 3cf8c98

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ assert!(nums == [2, 3]);
4040
let nums = queue.map(nums, |x| x.to_string());
4141
assert!(nums[0] == "2");
4242
```
43+
44+
# Sources
45+
46+
Dispatch sources monitor system objects and deliver events to a target queue.
47+
48+
```
49+
use dispatch::{Queue, QueueAttribute, SourceBuilder};
50+
use dispatch::source::{Proc, PROC_FORK};
51+
52+
let pid = 123;
53+
let queue = Queue::create("com.example.rust", QueueAttribute::Serial);
54+
let mut source_builder = SourceBuilder::new(
55+
Proc { pid: pid, flags: PROC_FORK }, &queue).unwrap();
56+
source_builder.event_handler(|source| {
57+
// process 123 forked
58+
});
59+
let source = source_builder.resume();
60+
```
4361
*/
4462

4563
#![warn(missing_docs)]

0 commit comments

Comments
 (0)