Function concurrent::gc [] [src]

pub fn gc()

Collect garbage.

This function does two things:

  1. Export garbage from current thread to the global queue.
  2. Collect all the garbage and run destructors on the unused items.

If another thread is currently doing 2., it will block until it can be done. This makes it different from conc::try_gc(), which will skip the step.

Use case

This is really only neccesary in one case: If you want to ensure that all the destructors of inactive hazards in the current thread are run. If the destructors hold some special logic, you want to execute, this will force the (inactive) ones to run these destructors and thus execute the logic.

If you just want to reduce memory usage, you will probably be better off with conc::try_gc().

Other threads

This cannot collect un-propagated garbage accumulated locally in other threads. This will only collect the accumulated local and global (propagated) garbage.

Panic

If a destructor panics during the garbage collection, theis function will panic aswell.