pub struct BlockingIoManager {
poll: Option<Poll>,
events: Events,
sources: FxHashMap<ThreadId, Box<dyn WithSource>>,
}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: FxHashMap<ThreadId, Box<dyn WithSource>>Map between threads which are currently blocked and the underlying I/O source.
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<ThreadId>, Error>
pub fn poll( &mut self, timeout: Option<Duration>, ) -> Result<Vec<ThreadId>, 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 all threads that are ready because they received an I/O event.
Sourcepub fn register(
&mut self,
source: Box<dyn WithSource>,
thread: ThreadId,
interests: Interest,
)
pub fn register( &mut self, source: Box<dyn WithSource>, thread: ThreadId, interests: Interest, )
Register a blocking I/O source for a thread together with it’s poll interests.
The source will be deregistered automatically once an event for it is received.
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.
Sourcefn deregister(&mut self, thread: ThreadId)
fn deregister(&mut self, thread: ThreadId)
Deregister the event source for a thread. Returns the kind of I/O the thread was blocked on.
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: 64 bytes