1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Waking the event loop from other threads.
use fmt;
use Arc;
/// Asks the running app for a redraw from any thread: an emulator's serial
/// reader, a build, a network client. Cheap to clone; wake-ups that arrive
/// faster than frames are drawn coalesce.
///
/// ```
/// use std::sync::atomic::{AtomicUsize, Ordering};
/// use std::sync::Arc;
///
/// let count = Arc::new(AtomicUsize::new(0));
/// let seen = count.clone();
/// let waker = scopekit::Waker::new(move || { seen.fetch_add(1, Ordering::Relaxed); });
/// let w = waker.clone();
/// std::thread::spawn(move || w.wake()).join().unwrap();
/// assert_eq!(count.load(Ordering::Relaxed), 1);
/// ```