pub struct WatcherProxy { /* private fields */ }
Implementations§
Source§impl WatcherProxy
impl WatcherProxy
Sourcepub fn new(channel: AsyncChannel) -> Self
pub fn new(channel: AsyncChannel) -> Self
Create a new Proxy for fuchsia.memorypressure/Watcher.
Sourcepub fn take_event_stream(&self) -> WatcherEventStream
pub fn take_event_stream(&self) -> WatcherEventStream
Get a Stream of events from the remote end of the protocol.
§Panics
Panics if the event stream was already taken.
Sourcepub fn on_level_changed(
&self,
level: Level,
) -> QueryResponseFut<(), DefaultFuchsiaResourceDialect>
pub fn on_level_changed( &self, level: Level, ) -> QueryResponseFut<(), DefaultFuchsiaResourceDialect>
Sent to the registered client when the memory pressure level changes.
level
: indicates the current memory pressure level.
Will also be invoked on initial connection via RegisterWatcher
, so that a newly
registered client can discover the current memory pressure level.
The watcher must immediately reply with a message to acknowledge that it has received the level change notification, and has initiated required actions as a result. It may then continue to reclaim memory asynchronously after sending the acknowledgement.
Some helpful guidelines for clients:
-
The watcher will be notified of new pressure level changes only after a reply corresponding to the previous message has been received by the provider. If multiple level transitions occur during that time, the watcher will be notified of the latest pressure level.
-
The level changes are edge-triggered, and clients are expected to maintain local state to track the current pressure level, if required. For example, a job might be notified of a CRITICAL level and drop all its caches as a result. Some time after this, it might want to trigger an activity that causes a fair amount of memory to be allocated. At this point, the job is expected to remember that the last pressure level it saw was CRITICAL, and refrain from triggering the memory-intensive activity.
-
As a performance optimization, the provider may decide to skip sending messages for some pressure level changes. For example, when oscillating across the NORMAL / WARNING boundary, it might not be worth notifying clients of every single transition. The provider might rate-limit messages in this case. On a similar note, the provider may decide to send repeated messages at the same pressure level, particularly CRITICAL, to indicate that further action needs to be taken.
Trait Implementations§
Source§impl Clone for WatcherProxy
impl Clone for WatcherProxy
Source§fn clone(&self) -> WatcherProxy
fn clone(&self) -> WatcherProxy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for WatcherProxy
impl Debug for WatcherProxy
Source§impl Proxy for WatcherProxy
impl Proxy for WatcherProxy
Source§type Protocol = WatcherMarker
type Protocol = WatcherMarker
Proxy
controls.Source§fn from_channel(inner: AsyncChannel) -> Self
fn from_channel(inner: AsyncChannel) -> Self
Source§fn into_channel(self) -> Result<AsyncChannel, Self>
fn into_channel(self) -> Result<AsyncChannel, Self>
Source§fn as_channel(&self) -> &AsyncChannel
fn as_channel(&self) -> &AsyncChannel
§fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>
fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>
Source§impl WatcherProxyInterface for WatcherProxy
impl WatcherProxyInterface for WatcherProxy
type OnLevelChangedResponseFut = QueryResponseFut<()>
fn on_level_changed(&self, level: Level) -> Self::OnLevelChangedResponseFut
Auto Trait Implementations§
impl Freeze for WatcherProxy
impl !RefUnwindSafe for WatcherProxy
impl Send for WatcherProxy
impl Sync for WatcherProxy
impl Unpin for WatcherProxy
impl !UnwindSafe for WatcherProxy
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)