streaming_crypto/core_api/parallelism/
policy.rs1pub struct HybridCompactionPolicy {
9 pub threshold: usize,
10 pub compacted: bool,
11}
12
13impl HybridCompactionPolicy {
14 pub fn new(threshold: usize) -> Self {
15 Self { threshold, compacted: false }
16 }
17
18 pub fn should_compact(&self, current_size: usize) -> bool {
19 current_size >= self.threshold
20 }
21
22 pub fn mark_compacted(&mut self) {
23 self.compacted = true;
24 }
25}
26
27pub fn spawn_scheduler_cycle(policy: &mut HybridCompactionPolicy, log_size: usize) {
29 if policy.should_compact(log_size) {
30 policy.mark_compacted();
31 }
33}