pub struct DatabaseInstanceContextController { /* private fields */ }
Implementations§
source§impl DatabaseInstanceContextController
impl DatabaseInstanceContextController
pub fn new(energy_monitor: Arc<dyn EnergyMonitor>) -> 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::remove
d.
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
.
pub fn update_metrics(&self)
pub fn start_disk_monitor(&self)
Trait Implementations§
source§impl Clone for DatabaseInstanceContextController
impl Clone for DatabaseInstanceContextController
source§fn clone(&self) -> DatabaseInstanceContextController
fn clone(&self) -> DatabaseInstanceContextController
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for DatabaseInstanceContextController
impl !RefUnwindSafe for DatabaseInstanceContextController
impl Send for DatabaseInstanceContextController
impl Sync for DatabaseInstanceContextController
impl Unpin for DatabaseInstanceContextController
impl !UnwindSafe for DatabaseInstanceContextController
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more