Skip to main content

Engine

Struct Engine 

Source
pub struct Engine<E, Bk, C, K>
where E: EpochId + 'static, Bk: IoBackend, K: StampClock,
{ pub core: DurableIoCore<E, <Bk as IoBackend>::Buffer, C, K>, pub backend: Bk, pub requests: Vec<ProviderRequest<DioringIds<E, <K as StampClock>::Instant>>>, /* private fields */ }
Expand description

A core and its backend, acted on together (DI-D-53). E is the epoch-id type, Bk the backend, C the consumer’s per-operation context, and K the clock failures are stamped with.

Fields§

§core: DurableIoCore<E, <Bk as IoBackend>::Buffer, C, K>

The core, which decides.

§backend: Bk

The backend, which runs the I/O the core asks for.

§requests: Vec<ProviderRequest<DioringIds<E, <K as StampClock>::Instant>>>

Requests for the consumer’s provider the core has made, in order, for the driver to make with its lock released.

Implementations§

Source§

impl<E, Bk, C, K> Engine<E, Bk, C, K>
where E: EpochId + 'static, Bk: IoBackend, K: StampClock,

Source

pub fn new( core: DurableIoCore<E, <Bk as IoBackend>::Buffer, C, K>, backend: Bk, ) -> Engine<E, Bk, C, K>

A core and its backend, with no request outstanding.

Source

pub fn act( &mut self, actions: CoreActions<DioringIds<E, <K as StampClock>::Instant>, <Bk as IoBackend>::Buffer>, ) -> bool

Act on what the core asked for: push each submission, handing a refused one back to the core, which keeps it or ends it (DI-D-54) and says what that made due, acted on in turn; keep each provider request, in the order made; and ring the doorbell once for everything pushed. Whether entries became poppable, or the doorbell failed, which a consumer’s pop rings again and reports (DI-7+.2).

A backend only queues what it is pushed, so the doorbell is the engine’s to ring, once for a batch. A push refused because the queue is full is made once more after the doorbell has made room: the one condition that retry is for.

It ends: a refusal either is kept, making nothing due, or ends one submission for good.

Source

pub fn drain(&mut self) -> bool

Drain the backend to empty, feeding each completion to the core and acting on what it makes due, until a pass pops nothing; each pass first issues what is queued. Whether entries became poppable, or a doorbell failed or the completions could not be read, which a consumer’s pop reports (DI-7+.2).

What the backend refused before needs no step of its own: the core re-emits it with the actions of every completion, so the pop that makes room is the one that re-pushes it. A backend that cannot read its completions ends the drain: they stay where they are, for the next, and the fault is kept for take_fault.

Source

pub fn take_fault(&mut self) -> Option<IoFault>

The fault the backend gave when a drain tried to read its completions, once: the first since it was last taken, unless a later read has worked, which makes it stale. A backend that cannot read its completions is not one to go on with, and the consumer’s remedy is to drop the instance.

Source

pub fn take_attention(&mut self) -> bool

Whether a doorbell rung for a consumer’s push failed since this was last asked, so the driver is to tell the consumer, whose pop rings it again.

Source

pub fn write( &mut self, target: IoTargetKey, offset: u64, data: SubmissionData<<Bk as IoBackend>::Buffer>, epoch: Epoch<DioringIds<E, <K as StampClock>::Instant>>, context: C, options: WriteOptions<DioringIds<E, <K as StampClock>::Instant>>, ) -> Result<OpId, PushError<DioringIds<E, <K as StampClock>::Instant>, <Bk as IoBackend>::Buffer, C>>

Write data to target at offset, tagged epoch, through the backend.

§Errors

As DurableIoCore::write.

Source

pub fn read( &mut self, target: IoTargetKey, offset: u64, data: SubmissionData<<Bk as IoBackend>::Buffer>, context: C, options: ReadOptions<DioringIds<E, <K as StampClock>::Instant>>, ) -> Result<OpId, PushError<DioringIds<E, <K as StampClock>::Instant>, <Bk as IoBackend>::Buffer, C>>

Read from target at offset into data, through the backend.

§Errors

As DurableIoCore::read.

Source

pub fn make_durable_through( &mut self, through: Epoch<DioringIds<E, <K as StampClock>::Instant>>, ) -> Result<(DurabilityRequest<DioringIds<E, <K as StampClock>::Instant>>, bool), SealError<DioringIds<E, <K as StampClock>::Instant>>>

Seal through through, acting on what it made due: the answer, and whether entries became poppable.

§Errors

As DurableIoCore::make_durable_through.

Source

pub fn take_requests( &mut self, ) -> Vec<ProviderRequest<DioringIds<E, <K as StampClock>::Instant>>>

The provider requests made so far, in order, taken for the driver to make.

Auto Trait Implementations§

§

impl<E, Bk, C, K> !RefUnwindSafe for Engine<E, Bk, C, K>

§

impl<E, Bk, C, K> !UnwindSafe for Engine<E, Bk, C, K>

§

impl<E, Bk, C, K> Freeze for Engine<E, Bk, C, K>

§

impl<E, Bk, C, K> Send for Engine<E, Bk, C, K>
where DurableIoCore<E, <Bk as IoBackend>::Buffer, C, K>: Send, Bk: Send, Vec<ProviderRequest<DioringIds<E, <K as StampClock>::Instant>>>: Send,

§

impl<E, Bk, C, K> Sync for Engine<E, Bk, C, K>
where DurableIoCore<E, <Bk as IoBackend>::Buffer, C, K>: Sync, Bk: Sync, Vec<ProviderRequest<DioringIds<E, <K as StampClock>::Instant>>>: Sync,

§

impl<E, Bk, C, K> Unpin for Engine<E, Bk, C, K>

§

impl<E, Bk, C, K> UnsafeUnpin for Engine<E, Bk, C, K>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.