pub struct Mutator {
pub tid: u16,
pub rec: Arc<ThreadRecord>,
/* private fields */
}Fields§
§tid: u16§rec: Arc<ThreadRecord>Implementations§
Source§impl Mutator
impl Mutator
Sourcepub fn new(rec: Arc<ThreadRecord>) -> Self
pub fn new(rec: Arc<ThreadRecord>) -> Self
Creates the context for an already-registered thread.
Sourcepub fn set_young_alloc(&mut self, on: bool)
pub fn set_young_alloc(&mut self, on: bool)
Whether new objects start young (see catallaxy_gc::LocalHeap::set_young_alloc).
Sourcepub fn sharing(other: &Mutator) -> Self
pub fn sharing(other: &Mutator) -> Self
A second context for the same thread (a fiber): same heap and thread record, its own
handle stack. Release it with Mutator::free_handles.
Sourcepub unsafe fn free_handles(&mut self)
pub unsafe fn free_handles(&mut self)
Frees the handle stack of a context made by Mutator::sharing.
§Safety
No root source may still reference the handles.
Sourcepub fn heap_ptr(&self) -> *mut LocalHeap
pub fn heap_ptr(&self) -> *mut LocalHeap
Raw pointer to the allocator, for registration with the collector.
Sourcepub fn release_pages(&mut self)
pub fn release_pages(&mut self)
Returns the thread’s pages to the global pool (on thread exit, in native state).
Sourcepub fn scope<R>(&mut self, f: impl FnOnce(&mut Mutator) -> R) -> R
pub fn scope<R>(&mut self, f: impl FnOnce(&mut Mutator) -> R) -> R
Runs f with a handle scope; handles rooted inside are released afterwards.
pub fn root(&mut self, v: Value) -> Handle
pub fn get(&self, h: Handle) -> Value
pub fn set(&mut self, h: Handle, v: Value)
Sourcepub fn handle_mark(&self) -> usize
pub fn handle_mark(&self) -> usize
The current depth of the handle stack, for Mutator::release_handles. Lets foreign
code (the C API) manage scopes explicitly.
Sourcepub fn release_handles(&mut self, mark: usize)
pub fn release_handles(&mut self, mark: usize)
Releases every handle rooted since mark.
Sourcepub fn handle_values(&self) -> &[Value]
pub fn handle_values(&self) -> &[Value]
Root values for the GC (called while this thread is stopped).
Sourcepub fn handles_ptr(&self) -> *const Vec<Value>
pub fn handles_ptr(&self) -> *const Vec<Value>
Pointer to the handle stack, for root sources that must not borrow the mutator.
pub fn alloc_raw(&mut self, size: usize, cls: &'static Class) -> *mut Header
pub fn alloc_instance(&mut self, cls: &'static Class) -> Value
pub fn alloc_str(&mut self, s: &str) -> Value
Sourcepub fn int_from_big(&mut self, b: BigInt) -> Value
pub fn int_from_big(&mut self, b: BigInt) -> Value
Allocates a big integer, or returns a small int if it fits.