pub struct Heap {
pub heap: Box<Heap>,
}
Expand description
Wrapper over Comet heap.
Fields§
§heap: Box<Heap>
Implementations§
Source§impl Heap
impl Heap
Sourcepub fn defer(&self) -> DeferPoint
pub fn defer(&self) -> DeferPoint
Creates GC defer point.
Sourcepub fn new(size: Option<usize>) -> Self
pub fn new(size: Option<usize>) -> Self
Creates new Comet heap. if size
is < 1MB then it will be set to 1GB by default.
Examples found in repository?
examples/simple.rs (line 36)
33fn main() {
34 GCPlatform::initialize();
35
36 let mut heap = Heap::new(None);
37
38 let mut head = heap.allocate(Node {next: None,value: 0i32 });
39 head.next = Some(heap.allocate(Node {next: None, value: 1}));
40 heap.gc();
41
42 println!("{:p}",&head);
43 head.next = None;
44 heap.gc();
45 println!("{:p}", &head);
46}
Sourcepub fn gc(&mut self)
pub fn gc(&mut self)
Triggers GC cycle.
Examples found in repository?
examples/simple.rs (line 40)
33fn main() {
34 GCPlatform::initialize();
35
36 let mut heap = Heap::new(None);
37
38 let mut head = heap.allocate(Node {next: None,value: 0i32 });
39 head.next = Some(heap.allocate(Node {next: None, value: 1}));
40 heap.gc();
41
42 println!("{:p}",&head);
43 head.next = None;
44 heap.gc();
45 println!("{:p}", &head);
46}
Sourcepub fn allocate_(
&mut self,
size: usize,
vtable: usize,
idx: GCInfoIndex,
) -> Option<NonNull<GcPointerBase>>
pub fn allocate_( &mut self, size: usize, vtable: usize, idx: GCInfoIndex, ) -> Option<NonNull<GcPointerBase>>
Allocates GcPointerBase in Comet heap with all internal fields initialized correctly
Sourcepub fn allocate_raw(
&mut self,
size: usize,
vtable: usize,
idx: GCInfoIndex,
) -> *mut GcPointerBase
pub fn allocate_raw( &mut self, size: usize, vtable: usize, idx: GCInfoIndex, ) -> *mut GcPointerBase
Allocates raw memory in Comet heap.
Sourcepub fn allocate<T: GcCell + GCInfoTrait<T> + Trace + Finalize<T>>(
&mut self,
value: T,
) -> GcPointer<T>
pub fn allocate<T: GcCell + GCInfoTrait<T> + Trace + Finalize<T>>( &mut self, value: T, ) -> GcPointer<T>
Allocates T
on the GC heap with initializing all data correctly.
Examples found in repository?
examples/simple.rs (line 38)
33fn main() {
34 GCPlatform::initialize();
35
36 let mut heap = Heap::new(None);
37
38 let mut head = heap.allocate(Node {next: None,value: 0i32 });
39 head.next = Some(heap.allocate(Node {next: None, value: 1}));
40 heap.gc();
41
42 println!("{:p}",&head);
43 head.next = None;
44 heap.gc();
45 println!("{:p}", &head);
46}
Sourcepub fn add_constraint(&mut self, constraint: impl MarkingConstraint + 'static)
pub fn add_constraint(&mut self, constraint: impl MarkingConstraint + 'static)
Adds constraint to be executed before each gc cycle.
Sourcepub fn make_weak<T: GcCell>(&mut self, target: GcPointer<T>) -> WeakRef<T>
pub fn make_weak<T: GcCell>(&mut self, target: GcPointer<T>) -> WeakRef<T>
Allocates weak ref for T
.
pub fn collect_if_necessary(&mut self)
Auto Trait Implementations§
impl Freeze for Heap
impl !RefUnwindSafe for Heap
impl !Send for Heap
impl !Sync for Heap
impl Unpin for Heap
impl !UnwindSafe for Heap
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
Mutably borrows from an owned value. Read more