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
use super::*;

/// A handle to an ongoing pagecache transaction. Ensures
/// that any state which is removed from a shared in-memory
/// data structure is not destroyed until all possible
/// readers have concluded.
pub struct Tx {
    #[doc(hidden)]
    pub guard: Guard,
    #[doc(hidden)]
    pub ts: u64,
}

impl Tx {
    /// Creates a new Tx with a given timestamp.
    pub fn new(ts: u64) -> Self {
        Self { guard: pin(), ts }
    }
}

impl std::ops::Deref for Tx {
    type Target = Guard;

    fn deref(&self) -> &Guard {
        &self.guard
    }
}