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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Waking a blocked [`wait_events`](crate::Shell::wait_events) from another
//! thread.
//!
//! A program whose work arrives off the loop thread — a D-Bus reply, a socket,
//! a timer thread, a finished download — needs the loop to notice it while the
//! loop is asleep in [`wait_events`](crate::Shell::wait_events). A
//! [`ShellWaker`] is the handle that does it: cloned and sent to any thread,
//! where [`wake`](ShellWaker::wake) makes the current wait return, or the next
//! one return at once if none is running.
//!
//! **A wake carries nothing.** It is a doorbell, not a message: the program
//! puts its data in its own channel and then rings, and the loop, once
//! [`wait_events`](crate::Shell::wait_events) has returned, drains that
//! channel. That keeps every backend's mechanism the same size — a byte on a
//! pipe, a signalled event, one posted event — and no event type grows a
//! variant for data the shell never looks at.
//!
//! **Wakes coalesce.** Any number of wakes between two waits end at most the
//! next one or two of them early; none is ever lost, and none piles up. A loop
//! that wakes, drains its channel and waits again therefore never misses work
//! sent while it was draining.
use fmt;
use Arc;
/// What a backend's wake mechanism does when rung. One implementation per
/// backend; [`ShellWaker`] is the type every caller sees.
pub
/// Wakes one shell's [`wait_events`](crate::Shell::wait_events) from any
/// thread — see the [module docs](self).
///
/// From [`Shell::waker`](crate::Shell::waker). Cheap to clone, `Send` and
/// `Sync`, and valid for as long as anyone holds it: a wake after the shell is
/// gone does nothing.
/// A backend's [`waker`](crate::Shell::waker): the doorbell in `slot`, made
/// by `make` on the first ask and shared by every handle after.
///
/// `None`, logged, if `make` fails — the process out of descriptors or
/// handles — and asked again next time, since that can pass.
pub