Struct janetrs::JanetGc[][src]

pub struct JanetGc { /* fields omitted */ }
Expand description

The Janet Garbage Collector type.

It allows the use of garbage collection operations in the Janet public C API.

Implementations

impl JanetGc[src]

pub fn obtain() -> Self[src]

Obtain the JanetGc.

pub fn collect(&self)[src]

Run the garbage collection if there is nothing locking or suspending the garbage collector, like an active JanetGcLockGuard or a call to a Janet C API that locks the GC.

If there is something locking the garbage collection, it simply does a no-op.

pub fn lock(&self) -> JanetGcLockGuard[src]

Lock the Janet GC and suspend any garbage collection until the guard is dropped.

If there is any attempt to manually trigger the garbage collection while there is a JanetGcLockGuard active (or any unsafe call to the Janet C API locking the GC)

pub fn unlock(guard: JanetGcLockGuard)[src]

Immediately drops the guard, and consequently unlocks the Janet GC.

This function is equivalent to calling drop on the guard but is more self-documenting. Alternately, the guard will be automatically dropped when it goes out of scope.

Example:

use janetrs::JanetGc;

let gc = JanetGc::obtain();

let mut guard = gc.lock();

// do stuff with the Janet GC locked

JanetGc::unlock(guard);

pub fn root(&self, value: Janet) -> JanetGcRootGuard[src]

Roots the value to the GC. This prevents the GC from removing the value and all of its children in a garbage collection.

The returned guard will unroot the value when dropped.

pub fn unroot(guard: JanetGcRootGuard)[src]

Immediately drops the guard, and consequently unlocks the Janet GC.

This function is equivalent to calling drop on the guard but is more self-documenting. Alternately, the guard will be automatically dropped when it goes out of scope.

Trait Implementations

impl Debug for JanetGc[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for JanetGc[src]

fn default() -> JanetGc[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

impl RefUnwindSafe for JanetGc

impl !Send for JanetGc

impl !Sync for JanetGc

impl Unpin for JanetGc

impl UnwindSafe for JanetGc

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.