pub struct GcState { /* private fields */ }Expand description
What the collector knows about the pools between two allocations.
This lives with the pools rather than with one run of the interpreter because the pools do: a host that calls into a resident program many times keeps every object the earlier calls left behind, and a collector that forgot its free lists and started its thresholds over on each call would run a full mark and sweep on the first few allocations of every call once the pools had grown past the starting threshold, and would never reuse a slot the previous call had freed. A cycle in progress carries over between calls the same way.
Implementations§
Source§impl GcState
impl GcState
Sourcepub const TORTURE: bool = TORTURE
pub const TORTURE: bool = TORTURE
Whether this build runs a cycle on every allocation, a unit of work at
a time, which is what the gc-torture feature turns on.
Sourcepub fn stats(
&self,
objs: &ObjectPool,
maps: &MapPool,
strings: &StringPool,
) -> GcStats
pub fn stats( &self, objs: &ObjectPool, maps: &MapPool, strings: &StringPool, ) -> GcStats
What the collector has done over objs, maps and strings, the
pools this state collects.
Sourcepub fn collect(
&mut self,
objs: &mut ObjectPool,
maps: &mut MapPool,
strings: &mut StringPool,
registers: &[Data],
budget: u32,
) -> bool
pub fn collect( &mut self, objs: &mut ObjectPool, maps: &mut MapPool, strings: &mut StringPool, registers: &[Data], budget: u32, ) -> bool
Collection work for a host to do while its program is idle: carries
the cycle in progress forward by about budget units, beginning one
first if the pools have grown enough since the last to be worth it.
Answers whether no collection work is left.
registers are the roots. The host calls this between calls into the
program, when the registers are the only roots there are.
Beginning a cycle reads every root at once, whatever the budget; after
that a step stops within one chunk or one mark word of the budget. A
cycle begins only when some pool has grown by half its live set (and by
at least [MIN_GC_THRESHOLD] slots) since the last one and has fewer
than an eighth of its slots free, or the program has allocated half as
many bytes as the last cycle found live (and at least
[MIN_BYTE_THRESHOLD]); otherwise the call does nothing.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GcState
impl RefUnwindSafe for GcState
impl Send for GcState
impl Sync for GcState
impl Unpin for GcState
impl UnsafeUnpin for GcState
impl UnwindSafe 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<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);