pub struct PowerStatsManager { /* private fields */ }Expand description
Handle to the per-Kernel singleton that watches fuchsia.hardware.power.stats.Service on
the kernel’s main async executor and tracks discovered power entities for kernel subsystems and
modules.
Discovery is performed asynchronously as providers appear in /svc, while
Self::entity_stats looks up the PowerStatsProvider serving a given entity and issues the
synchronous GetStats call outside the internal lock.
Implementations§
Source§impl PowerStatsManager
impl PowerStatsManager
Sourcepub fn get_or_init(kernel: &Kernel) -> Self
pub fn get_or_init(kernel: &Kernel) -> Self
Returns the per-Kernel PowerStatsManager, starting the asynchronous watcher for
/svc/fuchsia.hardware.power.stats.Service on first access.
Sourcepub fn get_or_init_for_testing(kernel: &Kernel) -> Self
pub fn get_or_init_for_testing(kernel: &Kernel) -> Self
Returns the per-Kernel PowerStatsManager for unit testing, suppressing the
background /svc watcher if it has not been started yet.
Sourcepub fn add_provider_for_testing(kernel: &Kernel, provider: PowerStatsProvider)
pub fn add_provider_for_testing(kernel: &Kernel, provider: PowerStatsProvider)
Registers provider with the per-Kernel PowerStatsManager for unit testing,
suppressing the background /svc watcher if it has not been started yet.
Sourcepub fn watch_providers<F>(&self, kernel: &Kernel, listener: F)
pub fn watch_providers<F>(&self, kernel: &Kernel, listener: F)
Registers listener to be invoked for every PowerStatsProvider that announces newly
discovered power entities, including any providers discovered prior to this call.
Each discovered entity name is announced at most once across all provider notifications:
if a provider disconnects and a restarted provider re-registers the same entities,
Self::entity_stats switches to the new provider while listeners are only invoked for
any previously unannounced entities.
Listeners are invoked while holding PowerStatsManagerLock, which is ordered before
DeviceRegistryStateLevel and
SimpleDirectoryEntriesLock so listeners may
register devices and sysfs nodes without race windows between existing and newly discovered
providers. Because PowerStatsManagerLock is held during the callback, listener must
not synchronously re-enter PowerStatsManager methods.
Trait Implementations§
Source§impl Clone for PowerStatsManager
impl Clone for PowerStatsManager
Auto Trait Implementations§
impl !RefUnwindSafe for PowerStatsManager
impl !UnwindSafe for PowerStatsManager
impl Freeze for PowerStatsManager
impl Send for PowerStatsManager
impl Sync for PowerStatsManager
impl Unpin for PowerStatsManager
impl UnsafeUnpin for PowerStatsManager
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [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