pub struct SharedManager { /* private fields */ }Expand description
A shared manager that coordinates memory reclamation across executors.
The SharedManager is the central structure that keeps a number of registered executors,
a number of executors that passed the current epoch, and the current epoch number.
Executors register themselves with the SharedManager and get
a thread-local LocalManager, which they use to schedule memory for deallocation or dropping.
The SharedManager ensures that memory is only freed when it is safe — that is,
once all executors have advanced past the epoch in which the memory was retired.
§Usage
- Create a new
SharedManagerwithSharedManager::new. - For each executor (thread or runtime worker), call
SharedManager::register_new_executorto install a thread-localLocalManager. - Executors periodically call
LocalManager::maybe_pass_epochto advance epochs and allow reclamation. - When an executor is done, it must deregister with
unsafe { LocalManager::deregister() }.
§Example
You can find a very detailed example in the LocalManager’s docs.
Implementations§
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SharedManager.
This function initializes the global epoch and prepares the internal state for executor registration.
Sourcepub fn register_new_executor(&self)
pub fn register_new_executor(&self)
Registers a new executor in the current thread.
This creates and installs a thread-local LocalManager associated
with this SharedManager.
§Panics
Panics if the current thread already has a registered LocalManager.
Trait Implementations§
Source§fn clone(&self) -> SharedManager
fn clone(&self) -> SharedManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more