Skip to main content

BlockingIoManager

Struct BlockingIoManager 

Source
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: 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: BTreeMap<FdId, BlockingIoSource>

Map from source file description ids to the actual sources and their blocked threads.

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<'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 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.

The events also immediately get processed: threads get unblocked, and epoll readiness gets updated.

Source

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.

Source

pub fn register( &mut self, source_fd: FileDescriptionRef<dyn SourceFileDescription>, )

Register a source file description to the blocking I/O poll.

Source

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.

Source

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.

Source

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§

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.

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