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
//! CompactionGuard RAII type for the dream cycle.
//!
//! Why: Extracted from dream.rs to keep each file under the 500-SLOC cap
//! (#607). The guard ensures the `is_compacting` flag is always cleared on
//! exit, even on early errors or panics.
//! What: `CompactionGuard` claims `is_compacting` on construction and clears
//! it on drop. #9172: the claim is exclusive, so one palace handle runs one
//! dream cycle at a time.
//! Test: `dream::tests::dream_cycle_toggles_is_compacting`,
//! `dedup_survivor_tests::a_second_dream_cycle_on_a_dreaming_palace_loses_no_text`.
use Arc;
use ;
/// RAII guard that toggles a palace's `is_compacting` flag for the lifetime
/// of a dream cycle.
///
/// Why: A plain `flag.store(true)` at the top of `dream_cycle` and
/// `flag.store(false)` at the bottom leaks `true` if any pass returns an
/// error or panics, leaving the dashboard stuck on "dreaming". A Drop guard
/// guarantees the flag clears on every exit path.
/// What: Flips the supplied `AtomicBool` from `false` to `true` on
/// construction and back to `false` on drop. The dashboard reads the flag
/// with `Relaxed`; only the claim itself needs to be a single atomic step.
/// Test: `dream::tests::dream_cycle_toggles_is_compacting`.
pub