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]
impl JanetGc
[src]pub fn collect(&self)
[src]
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]
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]
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]
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]
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.