mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Add refcount logging to servo_arc.
Differential Revision: https://phabricator.services.mozilla.com/D32173
This commit is contained in:
parent
57868f571f
commit
9a9a4e12d5
10 changed files with 100 additions and 23 deletions
|
@ -40,7 +40,7 @@ impl<T> Deref for ArcSlice<T> {
|
|||
lazy_static! {
|
||||
// ThinArc doesn't support alignments greater than align_of::<u64>.
|
||||
static ref EMPTY_ARC_SLICE: ArcSlice<u64> = {
|
||||
ArcSlice(ThinArc::from_header_and_iter(ARC_SLICE_CANARY, iter::empty()))
|
||||
ArcSlice::from_iter_leaked(iter::empty())
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,19 @@ impl<T> ArcSlice<T> {
|
|||
ArcSlice(ThinArc::from_header_and_iter(ARC_SLICE_CANARY, items))
|
||||
}
|
||||
|
||||
/// Creates an Arc for a slice using the given iterator to generate the
|
||||
/// slice, and marks the arc as intentionally leaked from the refcount
|
||||
/// logging point of view.
|
||||
#[inline]
|
||||
pub fn from_iter_leaked<I>(items: I) -> Self
|
||||
where
|
||||
I: Iterator<Item = T> + ExactSizeIterator,
|
||||
{
|
||||
let thin_arc = ThinArc::from_header_and_iter(ARC_SLICE_CANARY, items);
|
||||
thin_arc.with_arc(|a| a.mark_as_intentionally_leaked());
|
||||
ArcSlice(thin_arc)
|
||||
}
|
||||
|
||||
/// Creates a value that can be passed via FFI, and forgets this value
|
||||
/// altogether.
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue