orx_linked_list/list/
reclaim.rs

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
use super::List;
use crate::variant::ListVariant;
use orx_pinned_vec::PinnedVec;
use orx_selfref_col::{MemoryPolicy, MemoryReclaimer, MemoryState, Node};

impl<V, M, P> List<V, M, P>
where
    V: ListVariant,
    M: MemoryPolicy<V>,
    P: PinnedVec<Node<V>>,
{
    /// Manually attempts to reclaim closed nodes.
    ///
    /// # Safety
    ///
    /// It is important to note that, memory reclaim operation might lead to reorganization of the nodes
    /// which invalidates the node indices obtained before the process.
    pub fn reclaim_closed_nodes(&mut self) -> (MemoryState, MemoryState) {
        let num_active_nodes = self.len();
        let old = self.0.memory_state();

        // let state_changed = SinglyReclaimer::reclaim(&mut self.0);
        let state_changed = <V::Reclaimer as MemoryReclaimer<V>>::reclaim_nodes(&mut self.0);
        self.0.nodes_mut().truncate(num_active_nodes);
        self.0.update_state(state_changed);

        (old, self.0.memory_state())
    }
}