<commit_before>use std::ptr;
use std::sync::Mutex;

use super::*;

pub struct Lru {
    shards: Vec<Mutex<Shard>>,
}

impl Lru {
    /// Instantiates a new `Lru` cache.
    pub fn new(cache_capacity: usize, cache_bits: usize) -> Lru {
        assert!(
            cache_bits <= 20,
            "way too many shards. use a smaller number of cache_bits"
        );
        let size = 1 << cache_bits;
        let shard_capacity = cache_capacity / size;

        Lru {
            shards: rep_no_copy![Mutex::new(Shard::new(shard_capacity)); size],
        }
    }

    /// Called when a page is accessed. Returns a Vec of pages to
    /// try to page-out. For each one of these, the caller is expected<commit_msg>mark Lru sync for rayon compatibility<commit_after>use std::ptr;
use std::sync::Mutex;

use super::*;

pub struct Lru {
    shards: Vec<Mutex<Shard>>,
}

unsafe impl Sync for Lru {}

impl Lru {
    /// Instantiates a new `Lru` cache.
    pub fn new(cache_capacity: usize, cache_bits: usize) -> Lru {
        assert!(
            cache_bits <= 20,
            "way too many shards. use a smaller number of cache_bits"
        );
        let size = 1 << cache_bits;
        let shard_capacity = cache_capacity / size;

        Lru {
            shards: rep_no_copy![Mutex::new(Shard::new(shard_capacity)); size],
        }
    }

    /// Called when a page is accessed. Returns a Vec of pages to
    /// try to page-out. For each one of these, the caller is expected
{'fraction_non_alphanumeric': 0.11254237288135593, 'fraction_numerical': 0.004067796610169492, 'mean_word_length': 2.272727272727273, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '451892', 'n_tokens_mistral': 475, 'n_tokens_neox': 469, 'n_words': 157}