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
52
53
54
55
56
57
58
59
60
61
62
63
64
use std::sync::atomic::{AtomicUsize, Ordering};
use crate::common::{CurrentSrc};
use crate::history::HistoryOptions;
use dochy_core::structs::RootObject;
use crate::imp::history::current_root_obj_info::current_root_obj_info::CurrentRootObjInfo;
use crate::imp::history::diff_and_cache::dochy_cache::DochyCache;
use crate::imp::history::current_root_obj_info::fifo_thread::FifoThread;
use std::sync::Mutex;
pub(crate) struct HistoryCacheItem {
peekable : PeekableCacheInfo,
synced : Mutex<SyncedItem>,
fifo_thread : FifoThread
}
impl HistoryCacheItem{
pub(crate) fn new(peekable : PeekableCacheInfo, synced : Mutex<SyncedItem>) -> HistoryCacheItem{
HistoryCacheItem{ peekable, synced, fifo_thread : FifoThread::new() }
}
pub(crate) fn peekable(&self) -> &PeekableCacheInfo{ &self.peekable }
pub(crate) fn synced(&self) -> &Mutex<SyncedItem>{ &self.synced }
pub(crate) fn fifo_thread(&self) -> &FifoThread{ &self.fifo_thread }
}
#[derive(Debug)]
pub struct PeekableCacheInfo{
queued : AtomicUsize,
current_src : CurrentSrc,
hash : u128,
history_options : HistoryOptions,
src_root : RootObject,
}
impl PeekableCacheInfo{
pub(crate) fn new(current_src : CurrentSrc,
hash : u128,
history_options : HistoryOptions,
src_root : RootObject) -> PeekableCacheInfo{
PeekableCacheInfo{ queued : AtomicUsize::new(0), current_src, hash, history_options, src_root }
}
pub fn queued_atomic(&self) -> &AtomicUsize{ &self.queued }
pub fn queued(&self) -> usize{ self.queued.load(Ordering::Relaxed) }
pub fn current_src(&self) -> &CurrentSrc{ &self.current_src }
pub fn hash(&self) -> u128{ self.hash }
pub fn history_options(&self) -> &HistoryOptions{ &self.history_options }
pub fn clone_src_root(&self) -> RootObject{ self.src_root.clone() }
}
pub(crate) struct SyncedItem{
cache : DochyCache,
current_root : Option<CurrentRootObjInfo>,
}
impl SyncedItem{
pub(crate) fn new(cache : DochyCache,
current_root : Option<CurrentRootObjInfo>) -> SyncedItem{
SyncedItem{ cache, current_root }
}
pub(crate) fn muts(&mut self) -> (&mut DochyCache, &mut Option<CurrentRootObjInfo>){
(&mut self.cache, &mut self.current_root)
}
}