pub struct ReadinessWatcher {
id: usize,
interests: RefCell<BTreeMap<ReadinessInterestKey, ReadinessInterest>>,
ready: RefCell<VecDeque<ReadinessInterestKey>>,
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§
§id: usizeGlobally unique identifier of the watcher.
interests: RefCell<BTreeMap<ReadinessInterestKey, ReadinessInterest>>A map of ReadinessInterests registered for this watcher. Each entry is
identified using a FdId FdNum tuple.
ready: RefCell<VecDeque<ReadinessInterestKey>>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
impl ReadinessWatcher
Sourcepub fn interests(
&self,
) -> Ref<'_, BTreeMap<ReadinessInterestKey, ReadinessInterest>>
pub fn interests( &self, ) -> Ref<'_, BTreeMap<ReadinessInterestKey, ReadinessInterest>>
Get a reference to the map of registered interests of the watcher together with their keys.
Sourcepub 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<(), ()>>
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.
Sourcepub fn update_interest<'tcx>(
self: &Rc<Self>,
key: ReadinessInterestKey,
ecx: &mut MiriInterpCx<'tcx>,
cb: impl FnOnce(&mut ReadinessInterest),
) -> InterpResult<'tcx, Option<()>>
pub fn update_interest<'tcx>( self: &Rc<Self>, key: ReadinessInterestKey, 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.
Sourcepub fn remove_interest<'tcx>(
self: &Rc<ReadinessWatcher>,
key: ReadinessInterestKey,
ecx: &mut MiriInterpCx<'tcx>,
) -> Option<()>
pub fn remove_interest<'tcx>( self: &Rc<ReadinessWatcher>, key: ReadinessInterestKey, ecx: &mut MiriInterpCx<'tcx>, ) -> Option<()>
Remove the interest registered for key.
This function returns None when no interest is registered
for the specified key.
Sourcepub fn add_blocked_thread(&self, thread_id: ThreadId)
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.
Sourcepub fn remove_blocked_thread(&self, thread_id: ThreadId)
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.
Sourcepub fn ready_count(&self) -> usize
pub fn ready_count(&self) -> usize
Get the amount of interests which are registered to this watcher and which are currently ready.
Sourcepub fn get_ready_interests<'tcx>(
&self,
count: usize,
ecx: &mut MiriInterpCx<'tcx>,
) -> InterpResult<'tcx, Vec<ReadinessInterest>>
pub fn get_ready_interests<'tcx>( &self, count: usize, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Vec<ReadinessInterest>>
Get at most the first count 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.
Sourcepub fn destroy<'tcx>(self, ecx: &mut MiriInterpCx<'tcx>)
pub fn destroy<'tcx>(self, ecx: &mut MiriInterpCx<'tcx>)
Destroy the watcher instance.
This also deregisters all interests of the watcher from the global readiness interest table.
Trait Implementations§
Source§impl Debug for ReadinessWatcher
impl Debug for ReadinessWatcher
Source§impl VisitProvenance for ReadinessWatcher
impl VisitProvenance for ReadinessWatcher
fn visit_provenance(&self, _visit: &mut VisitWith<'_>)
Auto Trait Implementations§
impl !Freeze for ReadinessWatcher
impl !RefUnwindSafe for ReadinessWatcher
impl !Sync for ReadinessWatcher
impl Send for ReadinessWatcher
impl Unpin for ReadinessWatcher
impl UnsafeUnpin for ReadinessWatcher
impl UnwindSafe for ReadinessWatcher
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
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: 120 bytes