pub struct DatabaseInstanceContextController { /* private fields */ }Implementations§
source§impl DatabaseInstanceContextController
impl DatabaseInstanceContextController
pub fn new() -> Self
sourcepub fn get(
&self,
database_instance_id: u64
) -> Option<(Arc<DatabaseInstanceContext>, Scheduler)>
pub fn get( &self, database_instance_id: u64 ) -> Option<(Arc<DatabaseInstanceContext>, Scheduler)>
Get the database instance state if it is already initialized.
Returns None if Self::get_or_try_init has not been called for the
given instance id before, or the state was explicitly Self::removed.
sourcepub fn get_or_try_init<F, E>(
&self,
database_instance_id: u64,
f: F
) -> Result<(Arc<DatabaseInstanceContext>, Scheduler), E>
pub fn get_or_try_init<F, E>( &self, database_instance_id: u64, f: F ) -> Result<(Arc<DatabaseInstanceContext>, Scheduler), E>
Get the database instance state, or initialize it if it is not present.
If the instance is not initialized yet, this method will block until
F returns. It will, however, release internal locks so calls to other
methods will not block.
After this method returns, the instance state becomes managed by the
controller until it is removed by calling Self::remove.
Note that Self::remove must be called eventually, even if this
method returns an Err result: in this case, Self::get returns
None (as one would expect), but the given database_instance_id is
nevertheless known to the controller.
sourcepub fn remove(
&self,
database_instance_id: u64
) -> Option<(Arc<DatabaseInstanceContext>, Scheduler)>
pub fn remove( &self, database_instance_id: u64 ) -> Option<(Arc<DatabaseInstanceContext>, Scheduler)>
Remove and return the state corresponding to database_instance_id.
Returns None if either the state is not known, or was not properly
initialized (i.e. Self::get_or_try_init returned an error).
This method may block if the instance state is currently being
initialized via Self::get_or_try_init.