pub struct GcState { /* private fields */ }Expand description
The process-wide object lists every interpreter’s collections walk.
Interpreter-owned policy and results live in GcInterpreterState; what is
here is shared because the lists are: an object is untracked from
default_dealloc, where no interpreter is in scope, so it has to be findable
without one.
Implementations§
Source§impl GcState
impl GcState
pub const fn new() -> Self
Sourcepub fn get_count(&self) -> (usize, usize, usize)
pub fn get_count(&self) -> (usize, usize, usize)
Get counts for all generations. Tracked objects are shared, so these are process-wide even though the thresholds they are compared against are per interpreter.
Sourcepub unsafe fn track_object(&self, obj: NonNull<PyObject>, owner: u16)
pub unsafe fn track_object(&self, obj: NonNull<PyObject>, owner: u16)
Track a new object (add to gen0) as owned by owner.
O(1) — intrusive linked list push_front, no hashing.
§Safety
obj must be a valid pointer to a PyObject
Sourcepub unsafe fn untrack_object(&self, obj: NonNull<PyObject>)
pub unsafe fn untrack_object(&self, obj: NonNull<PyObject>)
Untrack an object (remove from GC lists). O(1) — intrusive linked list remove by node pointer.
§Safety
obj must be a valid pointer to a PyObject that is currently tracked. The object’s memory must still be valid (pointers are read).
Sourcepub fn get_objects(
&self,
generation: Option<i32>,
owner: u16,
) -> Vec<PyObjectRef>
pub fn get_objects( &self, generation: Option<i32>, owner: u16, ) -> Vec<PyObjectRef>
Get the objects owner tracks (for gc.get_objects), plus the ones no
interpreter owns.
If generation is None, returns all such objects.
If generation is Some(n), returns those in generation n only.
Sourcepub fn get_freeze_count(&self) -> usize
pub fn get_freeze_count(&self) -> usize
Get count of frozen objects
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GcState
impl !RefUnwindSafe for GcState
impl !Send for GcState
impl !Sync for GcState
impl !UnwindSafe for GcState
impl Unpin for GcState
impl UnsafeUnpin for GcState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Helper for T
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more