pub struct GcInterpreterState {
pub generations: [GcGeneration; 3],
pub garbage: PyMutex<Vec<PyObjectRef>>,
pub py_garbage: PyListRef,
pub py_callbacks: PyListRef,
/* private fields */
}Expand description
Per-interpreter garbage collector state (≈ PyInterpreterState.gc).
The generation lists are process-wide (see GcState); what an interpreter
owns is the policy applied to them and the results — which objects its
collections consider, whether they run automatically, and where uncollectable
objects end up.
Fields§
§generations: [GcGeneration; 3]Per-generation thresholds and statistics.
garbage: PyMutex<Vec<PyObjectRef>>Uncollectable objects saved by this interpreter’s collections, drained
into py_garbage by gc.collect().
py_garbage: PyListRefgc.garbage
py_callbacks: PyListRefgc.callbacks
Implementations§
Source§impl GcInterpreterState
impl GcInterpreterState
pub fn new(ctx: &Context) -> Self
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if GC is enabled.
Relaxed, like GcGeneration::threshold: it is read once per
allocation, and an allocation racing gc.disable() may use either value.
Sourcepub fn get_debug(&self) -> GcDebugFlags
pub fn get_debug(&self) -> GcDebugFlags
Get debug flags
Sourcepub fn set_debug(&self, flags: GcDebugFlags)
pub fn set_debug(&self, flags: GcDebugFlags)
Set debug flags
Sourcepub fn get_threshold(&self) -> (u32, u32, u32)
pub fn get_threshold(&self) -> (u32, u32, u32)
Get thresholds for all generations
Sourcepub fn collect(&self, generation: usize) -> CollectResult
pub fn collect(&self, generation: usize) -> CollectResult
Perform garbage collection on the given generation
Sourcepub fn collect_force(&self, generation: usize) -> CollectResult
pub fn collect_force(&self, generation: usize) -> CollectResult
Force collection even if GC is disabled (for manual gc.collect() calls)
Sourcepub fn get_objects(&self, generation: Option<i32>) -> Vec<PyObjectRef>
pub fn get_objects(&self, generation: Option<i32>) -> Vec<PyObjectRef>
The tracked objects this interpreter can reach (for gc.get_objects).
Trait Implementations§
Source§impl Drop for GcInterpreterState
impl Drop for GcInterpreterState
Auto Trait Implementations§
impl !Freeze for GcInterpreterState
impl !RefUnwindSafe for GcInterpreterState
impl !Send for GcInterpreterState
impl !Sync for GcInterpreterState
impl !UnwindSafe for GcInterpreterState
impl Unpin for GcInterpreterState
impl UnsafeUnpin for GcInterpreterState
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