style: Add refcount logging to servo_arc.

Differential Revision: https://phabricator.services.mozilla.com/D32173
This commit is contained in:
Emilio Cobos Álvarez 2019-05-16 04:35:34 +02:00
parent 57868f571f
commit 9a9a4e12d5
10 changed files with 100 additions and 23 deletions

View file

@ -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]