pub struct Engine<E, Bk, C, K>{
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: BkThe 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>
impl<E, Bk, C, K> Engine<E, Bk, C, K>
Sourcepub fn new(
core: DurableIoCore<E, <Bk as IoBackend>::Buffer, C, K>,
backend: Bk,
) -> Engine<E, Bk, C, K>
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.
Sourcepub fn act(
&mut self,
actions: CoreActions<DioringIds<E, <K as StampClock>::Instant>, <Bk as IoBackend>::Buffer>,
) -> bool
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.
Sourcepub fn drain(&mut self) -> bool
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.
Sourcepub fn take_fault(&mut self) -> Option<IoFault>
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.
Sourcepub fn take_attention(&mut self) -> bool
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.
Sourcepub 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>>
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>>
Sourcepub 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>>
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>>
Sourcepub 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>>>
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
Sourcepub fn take_requests(
&mut self,
) -> Vec<ProviderRequest<DioringIds<E, <K as StampClock>::Instant>>>
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.