[PATCH v2 3/5] rust: maple_tree: add MapleTree::lock() and load()
Daniel Almeida
daniel.almeida at collabora.com
Tue Aug 19 10:22:31 PDT 2025
Ah, something else,
[…]
>> + /// Load the value at the given index.
>> + ///
>> + /// # Examples
>> + ///
>> + /// Read the value while holding the spinlock.
>> + ///
>> + /// ```
>> + /// use kernel::maple_tree::{MapleTree, InsertErrorKind};
>> + ///
>> + /// let tree = KBox::pin_init(MapleTree::<KBox<i32>>::new(), GFP_KERNEL)?;
>> + ///
>> + /// let ten = KBox::new(10, GFP_KERNEL)?;
>> + /// let twenty = KBox::new(20, GFP_KERNEL)?;
>> + /// tree.insert(100, ten, GFP_KERNEL)?;
>> + /// tree.insert(200, twenty, GFP_KERNEL)?;
>> + ///
>> + /// let mut lock = tree.lock();
>> + /// assert_eq!(lock.load(100), Some(&mut 10));
>> + /// assert_eq!(lock.load(200), Some(&mut 20));
>> + /// assert_eq!(lock.load(300), None);
>> + /// # Ok::<_, Error>(())
>> + /// ```
>> + ///
>> + /// Increment refcount while holding spinlock and read afterwards.
This sentence can be improved.
More information about the maple-tree
mailing list