pub struct BlockingIoManager {
poll: Option<Poll>,
events: Events,
sources: BTreeMap<FdId, (FileDescriptionRef<dyn WithSource>, FxHashMap<InterestReceiver, Interest>)>,
}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.
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, (FileDescriptionRef<dyn WithSource>, FxHashMap<InterestReceiver, Interest>)>Map from source ids to the actual sources and their registered receivers together with their associated interests.
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(
&mut self,
timeout: Option<Duration>,
) -> Result<Vec<(InterestReceiver, FileDescriptionRef<dyn WithSource>)>, Error>
pub fn poll( &mut self, timeout: Option<Duration>, ) -> Result<Vec<(InterestReceiver, FileDescriptionRef<dyn WithSource>)>, 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.
Returns the interest receivers for all file descriptions which received an I/O event together with the file description they were registered for.
Sourcepub fn register(
&mut self,
source_fd: FileDescriptionRef<dyn WithSource>,
receiver: InterestReceiver,
interest: Interest,
)
pub fn register( &mut self, source_fd: FileDescriptionRef<dyn WithSource>, receiver: InterestReceiver, interest: Interest, )
Register an interest for a blocking I/O source.
As the OS can always produce spurious wake-ups, it’s the callers responsibility to verify the requested I/O interests are really ready and to register again if they’re not.
It’s assumed that no interest is already registered for this source with the same reason!
Sourcepub fn deregister(&mut self, source_id: FdId, receiver: InterestReceiver)
pub fn deregister(&mut self, source_id: FdId, receiver: InterestReceiver)
Deregister an interest from a blocking I/O source.
The receiver is assumed to be registered for the provided source!
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