Skip to main content

EntryDelivery

Struct EntryDelivery 

Source
pub struct EntryDelivery<D: DurableRing<Readiness = Event> + Send + 'static> { /* private fields */ }
Expand description

The Model A front end: owns an instance and hands its entries, one at a time and in queue order, to a handler on thread-pool threads. Derefs to the DeliveryHandle through which the instance’s operations are reached. For an instance whose readiness signal is an Event, which it waits on through the thread pool.

§The handler

Called with a DeliveryEvent: each entry, in queue order, and a failure of the instance’s pop when it has one to report, which a handler that ignores is a delivery that stalls without saying so. Called on a pool thread, never twice at once, with the instance’s lock released. It must not panic – a panic unwinds into the thread pool’s callback and aborts the process – and while it runs no further entry is delivered, so a handler that blocks holds up delivery, and holds up into_inner and drop, which wait for it.

§Ending

Drop, close and into_inner all quiesce the delivery first: no handler call is running or will start (DI-2.7 point 5), so none runs once they have returned. Drop then drops the instance, and close closes it, each discarding any entry not yet delivered; into_inner hands the instance back with those entries still queued, so it can be popped directly or closed.

Implementations§

Source§

impl<D: DurableRing<Readiness = Event> + Send + 'static> EntryDelivery<D>

Source

pub fn new<F>( ring: D, on_entry: F, env: Option<&mut CallbackEnviron<'_>>, ) -> Result<Self, DeliverySetupError<D, F>>
where F: FnMut(DeliveryEvent<EntryOf<D>>, &DeliveryHandle<D>) + Send + 'static,

Take ring and deliver its entries to on_entry, on the default thread pool, or on the pool and priority env selects.

Entries already queued when the ring is handed over are delivered: the readiness signal may already have been consumed, so this arms the wait and then sets the signal itself.

§Errors

A DeliverySetupError handing back the instance and the handler, when duplicating the readiness signal, creating the thread-pool wait, or setting the signal fails. Only the first is reached by a test: the others fail when the process cannot get another handle or the thread pool cannot create a wait.

Source

pub fn into_inner(self) -> D

Quiesce the delivery and hand back the instance, with any entry not yet delivered still in its queue.

Source

pub fn close(self) -> Leftovers<D::Ids, D::Buffer, D::Context>

Quiesce the delivery and end the instance with DurableRing::close, handing back what is left. Entries not yet delivered are discarded with it.

Methods from Deref<Target = DeliveryHandle<D>>§

Source

pub fn add_target( &self, key: IoTargetKey, target: D::Target, ) -> Result<(), AddTargetError<D::Target>>

Source

pub fn remove_target( &self, key: IoTargetKey, ) -> Result<D::Target, RemoveTargetError<D::Ids>>

Source

pub fn default_lineage(&self) -> HandleOf<D>

Source

pub fn mint_lineage(&self, description: Option<String>) -> HandleOf<D>

Source

pub fn lineages(&self) -> Vec<LineageInfo<D::Ids>>

Source

pub fn end_lineage( &self, handle: HandleOf<D>, ) -> Result<(), EndLineageError<D::Ids>>

Source

pub fn retire_lineage( &self, handle: HandleOf<D>, ) -> Result<(), RetireLineageError<D::Ids>>

Source

pub fn write( &self, file: IoTargetKey, offset: u64, buffer: D::Buffer, tag: Tag<'_, D::Ids>, context: D::Context, ) -> PushResult<D>
where D::Buffer: IoBuf,

Source

pub fn write_with( &self, file: IoTargetKey, offset: u64, buffer: D::Buffer, tag: Tag<'_, D::Ids>, context: D::Context, options: WriteOptions<D::Ids>, ) -> PushResult<D>
where D::Buffer: IoBuf,

Source

pub fn read( &self, file: IoTargetKey, offset: u64, buffer: D::Buffer, context: D::Context, ) -> PushResult<D>
where D::Buffer: IoBufMut,

Source

pub fn read_with( &self, file: IoTargetKey, offset: u64, buffer: D::Buffer, context: D::Context, options: ReadOptions<D::Ids>, ) -> PushResult<D>
where D::Buffer: IoBufMut,

Source

pub fn make_durable_through( &self, through: Tag<'_, D::Ids>, ) -> Result<DurabilityRequest<D::Ids>, SealError<D::Ids>>

Source

pub fn durable_through( &self, lineage: Lin<D>, ) -> Result<Option<EpochIdOf<D>>, UnknownLineage<D::Ids>>

Source

pub fn sealed_through( &self, lineage: Lin<D>, ) -> Result<Option<EpochIdOf<D>>, UnknownLineage<D::Ids>>

Source

pub fn epoch_state( &self, epoch: Epoch<D::Ids>, ) -> Result<EpochState<D::Ids>, UnknownLineage<D::Ids>>

Source

pub fn resolve( &self, items: Vec<(TokenOf<D>, Resolution)>, ) -> Result<(), ResolveError<D::Ids>>

Source

pub fn import_failure( &self, scope: ImportScope<D::Ids>, ) -> Result<Imported<D::Ids>, UnknownLineage<D::Ids>>

Source

pub fn failures(&self) -> Vec<FailureInfo<D::Ids>>

Source

pub fn take_token(&self, failure: FailureIdOf<D>) -> Option<TokenOf<D>>

Source

pub fn with_registered_buffer<R>( &self, i: u32, f: impl FnOnce(&[u8]) -> R, ) -> Result<R>

Run f on the bytes of registered buffer i, under the front end’s lock.

§Errors

As RegisteredBufferRing::with_registered_buffer.

Source

pub fn with_registered_buffer_mut<R>( &self, i: u32, f: impl FnOnce(&mut [u8]) -> R, ) -> Result<R>

Run f on the bytes of registered buffer i, mutably, under the front end’s lock.

§Errors

As RegisteredBufferRing::with_registered_buffer_mut.

Source

pub fn write_registered( &self, file: IoTargetKey, offset: u64, span: RegisteredSpan, tag: Tag<'_, D::Ids>, context: D::Context, ) -> PushResult<D>

Source

pub fn write_registered_with( &self, file: IoTargetKey, offset: u64, span: RegisteredSpan, tag: Tag<'_, D::Ids>, context: D::Context, options: WriteOptions<D::Ids>, ) -> PushResult<D>

Source

pub fn read_registered( &self, file: IoTargetKey, offset: u64, span: RegisteredSpan, context: D::Context, ) -> PushResult<D>

Source

pub fn read_registered_with( &self, file: IoTargetKey, offset: u64, span: RegisteredSpan, context: D::Context, options: ReadOptions<D::Ids>, ) -> PushResult<D>

Trait Implementations§

Source§

impl<D: DurableRing<Readiness = Event> + Send + 'static> Deref for EntryDelivery<D>

Source§

type Target = DeliveryHandle<D>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &DeliveryHandle<D>

Dereferences the value.
Source§

impl<D: DurableRing<Readiness = Event> + Send + 'static> Drop for EntryDelivery<D>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<D> !RefUnwindSafe for EntryDelivery<D>

§

impl<D> !UnwindSafe for EntryDelivery<D>

§

impl<D> Freeze for EntryDelivery<D>
where Arc<Inner<D, dyn FnMut(DeliveryEvent<Entry<<D as DurableRing>::Ids, <D as DurableRing>::Buffer, <D as DurableRing>::Context>>, &DeliveryHandle<D>) + Send>>: Freeze,

§

impl<D> Send for EntryDelivery<D>
where Arc<Inner<D, dyn FnMut(DeliveryEvent<Entry<<D as DurableRing>::Ids, <D as DurableRing>::Buffer, <D as DurableRing>::Context>>, &DeliveryHandle<D>) + Send>>: Send,

§

impl<D> Sync for EntryDelivery<D>
where Arc<Inner<D, dyn FnMut(DeliveryEvent<Entry<<D as DurableRing>::Ids, <D as DurableRing>::Buffer, <D as DurableRing>::Context>>, &DeliveryHandle<D>) + Send>>: Sync,

§

impl<D> Unpin for EntryDelivery<D>
where Arc<Inner<D, dyn FnMut(DeliveryEvent<Entry<<D as DurableRing>::Ids, <D as DurableRing>::Buffer, <D as DurableRing>::Context>>, &DeliveryHandle<D>) + Send>>: Unpin,

§

impl<D> UnsafeUnpin for EntryDelivery<D>
where Arc<Inner<D, dyn FnMut(DeliveryEvent<Entry<<D as DurableRing>::Ids, <D as DurableRing>::Buffer, <D as DurableRing>::Context>>, &DeliveryHandle<D>) + Send>>: UnsafeUnpin,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.