Skip to main content

BlockingIoManager

Struct BlockingIoManager 

Source
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: Events

Buffer 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

Source

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.

Source

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 Some and contains Duration::ZERO, the poll doesn’t block and just reads all events since the last poll.
  • If the timeout is Some and contains a non-zero duration, it blocks at most for the specified duration.
  • If the timeout is None the poll blocks indefinitely until an event occurs.

Returns all threads that are ready because they received an I/O event.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

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