Constant style::bloom::BLOOM_KEY

source ·
const BLOOM_KEY: LocalKey<&'static AtomicRefCell<BloomFilter>>;
Expand description

Bloom filters are large allocations, so we store them in thread-local storage such that they can be reused across style traversals. StyleBloom is responsible for ensuring that the bloom filter is zeroed when it is dropped.

We intentionally leak this from TLS because we don’t have the guarantee of TLS destructors to run in worker threads.

Also, leaking it guarantees that we can borrow it indefinitely.

We could change this once https://github.com/rayon-rs/rayon/issues/688 is fixed, hopefully, which point we’d need to change the filter member below to be an arc and carry an owning reference around or so.