Struct coco::epoch::Garbage
[−]
[src]
pub struct Garbage { /* fields omitted */ }
: Use scope::defer_free and scope::defer_drop instead
A garbage queue.
This is where a concurrent data structure can store removed objects for deferred destruction.
Stored garbage objects are first kept in the garbage buffer. When the buffer becomes full, it's
objects are flushed into the garbage queue. Flushing can be manually triggered by calling
flush
.
Some garbage in the queue can be manually collected by calling collect
.
Methods
impl Garbage
[src]
fn new() -> Self
[src]
Returns a new, empty garbage queue.
unsafe fn defer_free<T>(&self, object: *const T, count: usize, scope: &Scope)
[src]
Adds an object that will later be freed.
The specified object is an array allocated at address object
and consists of count
elements of type T
.
This method inserts the object into the garbage buffer. When the buffers becomes full, it's objects are flushed into the garbage queue.
unsafe fn defer_drop<T>(&self, object: *const T, count: usize, scope: &Scope)
[src]
Adds an object that will later be dropped and freed.
The specified object is an array allocated at address object
and consists of count
elements of type T
.
This method inserts the object into the garbage buffer. When the buffers becomes full, it's objects are flushed into the garbage queue.
Note: The object must be Send + 'self
.
unsafe fn defer_destroy<T>(
&self,
destroy: unsafe fn(_: *mut T, _: usize),
object: *const T,
count: usize,
scope: &Scope
)
[src]
&self,
destroy: unsafe fn(_: *mut T, _: usize),
object: *const T,
count: usize,
scope: &Scope
)
Adds an object that will later be destroyed using destroy
.
The specified object is an array allocated at address object
and consists of count
elements of type T
.
This method inserts the object into the garbage buffer. When the buffers becomes full, it's objects are flushed into the garbage queue.
Note: The object must be Send + 'self
.
fn flush(&self, scope: &Scope)
[src]
Flushes the buffered garbage.
It is wise to flush the garbage just after passing a very large object to one of the
defer_*
methods, so that it isn't sitting in the buffer for a long time.
fn collect(&self, scope: &Scope)
[src]
Collects some garbage from the queue and destroys it.
Generally speaking, it's not necessary to call this method because garbage production already triggers garbage destruction. However, if there are long periods without garbage production, it might be a good idea to call this method from time to time.
This method collects several buffers worth of garbage objects.