mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 18:03:25 +00:00
Don't copy on write if this is the only reference
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
f13e5d12c1
commit
bec2c97637
@ -80,6 +80,21 @@ impl Frame {
|
||||
core::ptr::copy_nonoverlapping(src.as_ptr(), self.as_mut_ptr(), self.size());
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the reference count of the frame.
|
||||
///
|
||||
/// It returns the number of all references to the page, including all the
|
||||
/// existing page handles ([`Frame`]) and all the mappings in the page
|
||||
/// table that points to the page.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The function is safe to call, but using it requires extra care. The
|
||||
/// reference count can be changed by other threads at any time including
|
||||
/// potentially between calling this method and acting on the result.
|
||||
pub fn reference_count(&self) -> u32 {
|
||||
self.page.reference_count()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Page<FrameMeta>> for Frame {
|
||||
|
Reference in New Issue
Block a user