Skip to main content

ReadinessWatcher

Struct ReadinessWatcher 

Source
pub struct ReadinessWatcher {
    interests: RefCell<BTreeMap<(FdId, i32), ReadinessInterest>>,
    ready: RefCell<VecDeque<(FdId, i32)>>,
    queue: RefCell<VecDeque<ThreadId>>,
}
Expand description

A struct which stores ReadinessInterests for a set of file descriptions together with which interests are currently satisfied, and a list of threads which should be unblocked once a ReadinessInterest of the watcher is fulfilled.

Fields§

§interests: RefCell<BTreeMap<(FdId, i32), ReadinessInterest>>

A map of ReadinessInterests registered for this watcher. Each entry is identified using a FdId FdNum tuple.

§ready: RefCell<VecDeque<(FdId, i32)>>

The subset of interests that is currently considered “ready”. Stored separately so we can access it more efficiently. This is implemented as a queue so that with level-triggered interests, all events eventually get returned from ReadinessWatcher::get_ready_interests. The queue does not contain any duplicates.

§queue: RefCell<VecDeque<ThreadId>>

The queue of threads blocked on this watcher.

Implementations§

Source§

impl ReadinessWatcher

Source

pub fn add_interest<'tcx>( self: &Rc<Self>, fd_num: i32, relevant: Readiness, is_edge_triggered: bool, data: u64, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Result<(), ()>>

Add an interest for the file description to which the file descriptor fd_num belongs. relevant contains the readiness mask of relevant events. is_edge_triggered specifies whether the interest is edge-triggered (true) or level-triggered (false). data is the user-data which is associated with the interest.

The function returns Ok(()) when the interest was successfully added, and Err(()) when an interest with this key was already registered.

Source

pub fn update_interest<'tcx>( self: &Rc<Self>, key: (FdId, i32), ecx: &mut MiriInterpCx<'tcx>, cb: impl FnOnce(&mut ReadinessInterest), ) -> InterpResult<'tcx, Option<()>>

Update the interest which is registered for key. cb gets invoked with a mutable reference to the registered ReadinessInterest.

This function returns None when no interest is registered for the specified key.

Source

pub fn remove_interest( self: &Rc<ReadinessWatcher>, key: (FdId, i32), ) -> Option<()>

Remove the interest registered for key.

This function returns None when no interest is registered for the specified key.

Source

pub fn add_blocked_thread(&self, thread_id: ThreadId)

Add the thread with id thread_id to the queue of blocked threads which will be unblocked when the watcher becomes ready.

Source

pub fn remove_blocked_thread(&self, thread_id: ThreadId)

Remove all threads with id thread_id from the queue of blocked threads which will be unblocked when the watcher becomes ready.

Source

pub fn ready_count(&self) -> usize

Get the amount of interests which are registered to this watcher and which are currently ready.

Source

pub fn get_ready_interests<'tcx>( &self, max: usize, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Vec<ReadinessInterest>>

Get at most the first max ready interests from the ready queue.

If the interest is a level-triggered interest, it’s automatically added to the end of the queue again such that it will only be reported after all other ready interest have been returned.

This method returns at most every event from the ready queue once. This ensures that every returned interest is unique, even when there are level-triggered interests.

Trait Implementations§

Source§

impl Debug for ReadinessWatcher

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ReadinessWatcher

Source§

fn default() -> ReadinessWatcher

Returns the “default value” for a type. Read more
Source§

impl Drop for ReadinessWatcher

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl VisitProvenance for ReadinessWatcher

Source§

fn visit_provenance(&self, _visit: &mut VisitWith<'_>)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 112 bytes