|
18 | 18 | //! Those invariants shall be true at any time. |
19 | 19 | //! |
20 | 20 | //! 1. A node that has no parents and no handles can no longer be cancelled. |
21 | | -//! This is important during both cancellation and refcounting. |
| 21 | +//! This is important during both cancellation and refcounting. |
22 | 22 | //! |
23 | 23 | //! 2. If node B *is* or *was* a child of node A, then node B was created *after* node A. |
24 | | -//! This is important for deadlock safety, as it is used for lock order. |
25 | | -//! Node B can only become the child of node A in two ways: |
26 | | -//! - being created with `child_node()`, in which case it is trivially true that |
27 | | -//! node A already existed when node B was created |
28 | | -//! - being moved A->C->B to A->B because node C was removed in `decrease_handle_refcount()` |
29 | | -//! or `cancel()`. In this case the invariant still holds, as B was younger than C, and C |
30 | | -//! was younger than A, therefore B is also younger than A. |
| 24 | +//! This is important for deadlock safety, as it is used for lock order. |
| 25 | +//! Node B can only become the child of node A in two ways: |
| 26 | +//! - being created with `child_node()`, in which case it is trivially true that |
| 27 | +//! node A already existed when node B was created |
| 28 | +//! - being moved A->C->B to A->B because node C was removed in `decrease_handle_refcount()` |
| 29 | +//! or `cancel()`. In this case the invariant still holds, as B was younger than C, and C |
| 30 | +//! was younger than A, therefore B is also younger than A. |
31 | 31 | //! |
32 | 32 | //! 3. If two nodes are both unlocked and node A is the parent of node B, then node B is a child of |
33 | 33 | //! node A. It is important to always restore that invariant before dropping the lock of a node. |
|
0 commit comments