1mod bag;
2mod ct;
3mod epoch;
4mod global;
5mod local;
6mod shield;
7
8pub use epoch::DefinitiveEpoch;
9pub use local::Local;
10pub use shield::{unprotected, CowShield, FullShield, Shield, ThinShield, UnprotectedShield};
11
12use core::fmt;
13use global::Global;
14use std::sync::Arc;
15
16const ADVANCE_PROBABILITY: usize = 128;
17
18pub struct Collector {
24 global: Arc<Global>,
25}
26
27impl Collector {
28 pub fn new() -> Self {
29 Self {
30 global: Arc::new(Global::new()),
31 }
32 }
33
34 pub fn epoch(&self) -> DefinitiveEpoch {
35 self.global.definitive_epoch()
36 }
37
38 pub fn thin_shield(&self) -> ThinShield<'_> {
40 Global::thin_shield(&self.global)
41 }
42
43 pub fn full_shield(&self) -> FullShield<'_> {
44 Global::full_shield(&self.global)
45 }
46
47 pub fn local(&self) -> Local {
49 Global::local(&self.global)
50 }
51
52 pub fn try_collect_light(&self) -> Result<usize, ()> {
56 Global::try_collect_light(&self.global)
57 }
58}
59
60impl Default for Collector {
61 fn default() -> Self {
62 Self::new()
63 }
64}
65
66unsafe impl Send for Collector {}
67unsafe impl Sync for Collector {}
68
69impl fmt::Debug for Collector {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 f.pad("Collector { .. }")
72 }
73}