pub struct BlockingIoManager {
poll: Option<Poll>,
events: Events,
sources: BTreeMap<FdId, BlockingIoSource>,
}Expand description
Manager for managing blocking host I/O in a non-blocking manner.
We use [Poll] to poll for new I/O events from the OS for sources
registered using this manager.
The semantics of this manager are that host I/O sources are registered
to a [Poll] for their entire lifespan. Once host readiness events happen
on a registered source, its internal epoll readiness gets updated – even
when the source isn’t part of an active epoll instance. Also, for the entire
lifespan of the source, threads can be added which should be unblocked
once a certain BlockingIoSourceReadiness for an I/O source is satisfied.
Since blocking host I/O is inherently non-deterministic, no method on this
manager should be called when isolation is enabled. The only exception is
the BlockingIoManager::new function to create the manager. Everywhere else,
we assert that isolation is disabled!
Fields§
§poll: Option<Poll>Poll instance to monitor I/O events from the OS.
This is only None when Miri is run with isolation enabled.
events: EventsBuffer used to store the ready I/O events when calling [Poll::poll].
This is not part of the state and only stored to avoid allocating a
new buffer for every poll.
sources: BTreeMap<FdId, BlockingIoSource>Map from source file description ids to the actual sources and their blocked threads.
Implementations§
Source§impl BlockingIoManager
impl BlockingIoManager
Sourcepub fn new(communicate: bool) -> Result<Self, Error>
pub fn new(communicate: bool) -> Result<Self, Error>
Create a new blocking I/O manager instance based on the availability of communication with the host.
Sourcepub fn poll<'tcx>(
ecx: &mut MiriInterpCx<'tcx>,
timeout: Option<Duration>,
) -> InterpResult<'tcx, Result<(), Error>>
pub fn poll<'tcx>( ecx: &mut MiriInterpCx<'tcx>, timeout: Option<Duration>, ) -> InterpResult<'tcx, Result<(), Error>>
Poll for new I/O events from the OS or wait until the timeout expired.
- If the timeout is
Someand containsDuration::ZERO, the poll doesn’t block and just reads all events since the last poll. - If the timeout is
Someand contains a non-zero duration, it blocks at most for the specified duration. - If the timeout is
Nonethe poll blocks indefinitely until an event occurs.
The events also immediately get processed: threads get unblocked, and epoll readiness gets updated.
Sourcepub fn contains_source(&self, source_id: &FdId) -> bool
pub fn contains_source(&self, source_id: &FdId) -> bool
Return whether a source file description is currently registered in the blocking I/O poll. This can also be used to check whether a file description is a host I/O source.
Sourcepub fn register(
&mut self,
source_fd: FileDescriptionRef<dyn SourceFileDescription>,
)
pub fn register( &mut self, source_fd: FileDescriptionRef<dyn SourceFileDescription>, )
Register a source file description to the blocking I/O poll.
Sourcepub fn deregister(
&mut self,
source_id: FdId,
source: impl SourceFileDescription,
)
pub fn deregister( &mut self, source_id: FdId, source: impl SourceFileDescription, )
Deregister a source file description from the blocking I/O poll.
It’s assumed that the file description with id source_id is already
removed from the file description table.
Sourcefn add_blocked_thread(
&mut self,
source_id: FdId,
thread_id: ThreadId,
interest: BlockingIoInterest,
)
fn add_blocked_thread( &mut self, source_id: FdId, thread_id: ThreadId, interest: BlockingIoInterest, )
Add a new blocked thread to a registered source. The thread gets unblocked
once its BlockingIoInterest is fulfilled when calling
BlockingIoManager::poll.
It’s assumed that the thread of thread_id isn’t already blocked on
the source with id source_id and that this source is currently
registered.
Sourcepub fn remove_blocked_thread(&mut self, source_id: FdId, thread_id: ThreadId)
pub fn remove_blocked_thread(&mut self, source_id: FdId, thread_id: ThreadId)
Remove a blocked thread from a registered source.
It’s assumed that the thread of thread_id is blocked on the
source with id source_id and that this source is currently
registered.
Auto Trait Implementations§
impl Freeze for BlockingIoManager
impl !RefUnwindSafe for BlockingIoManager
impl !Send for BlockingIoManager
impl !Sync for BlockingIoManager
impl Unpin for BlockingIoManager
impl UnsafeUnpin for BlockingIoManager
impl !UnwindSafe for BlockingIoManager
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: 56 bytes