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
impl ReadinessWatcher
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: (FdId, i32),
ecx: &mut MiriInterpCx<'tcx>,
cb: impl FnOnce(&mut ReadinessInterest),
) -> InterpResult<'tcx, Option<()>>
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.
Sourcepub fn remove_interest(
self: &Rc<ReadinessWatcher>,
key: (FdId, i32),
) -> Option<()>
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.
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,
max: usize,
ecx: &mut MiriInterpCx<'tcx>,
) -> InterpResult<'tcx, Vec<ReadinessInterest>>
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
impl Debug for ReadinessWatcher
Source§impl Default for ReadinessWatcher
impl Default for ReadinessWatcher
Source§fn default() -> ReadinessWatcher
fn default() -> ReadinessWatcher
Source§impl Drop for ReadinessWatcher
impl Drop for ReadinessWatcher
Source§impl VisitProvenance for ReadinessWatcher
impl VisitProvenance for ReadinessWatcher
fn visit_provenance(&self, _visit: &mut VisitWith<'_>)
Auto Trait Implementations§
impl !DynSend for ReadinessWatcher
impl !DynSync for ReadinessWatcher
impl !Freeze for ReadinessWatcher
impl !RefUnwindSafe for ReadinessWatcher
impl !Send for ReadinessWatcher
impl !Sync for ReadinessWatcher
impl !UnwindSafe for ReadinessWatcher
impl Unpin for ReadinessWatcher
impl UnsafeUnpin 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: 112 bytes