Skip to main content

StreamCapture

Struct StreamCapture 

Source
pub struct StreamCapture { /* private fields */ }
Expand description

The graph capture of one pooled backend stream: where it sits in the lifecycle, and the memory its recorded launches were given.

The two travel together because neither is meaningful alone. A launch is remembered only while the window is recording, and what it remembers is only ever read once the window closes — so pairing them makes “buffers accumulate inside a window and nowhere else” a property of the type rather than a rule each backend has to keep.

Why the memory is worth keeping: a replay runs every recorded launch or none, so a replay that fails to enqueue leaves all of them exactly as they were, and so does a capture that never seals. Either way a later read of one has to fail rather than copy out bytes nothing wrote — which needs the list the launches themselves no longer hold, as bindings, so the failure can be tainted onto the allocations they resolve to.

Implementations§

Source§

impl StreamCapture

Source

pub fn record(&mut self, buffers: impl IntoIterator<Item = BufferBinding>)

Remember the memory a launch was given, when the stream is recording.

A no-op outside a window, where a launch that fails taints its own buffers on the spot and there is no graph to answer for them later.

Source

pub fn take_recorded(&mut self) -> Vec<BufferBinding>

The memory of the capture that just closed, each claim named once — the same buffer comes back once per recorded launch that was given it.

Deduplicated by claim_key, because the taint bookkeeping is range-exact and this list is what gets claimed and released: two tensors carved from one batched allocation are two claims, and collapsing them to their shared memory id would leave every sibling but one unclaimed on a refusal and unreleased on a replay.

Source

pub fn fail(&mut self, error: ServerError)

Doom the recording: work inside the window failed or was skipped — see Self::take_failure. The first failure wins, and a stream that is not recording has no window to doom.

Source

pub fn retain_host(&mut self, bytes: Bytes)

Keep bytes alive for the graph this recording seals into: a recorded copy holds their raw pointer and re-reads them on every replay, so they must not return to any pool or allocator while the graph lives. Handed to the graph by take_retained_host.

Only meaningful while recording — outside a window the bytes belong in the drop queue, whose fence knows when the device is done with them.

Source

pub fn take_retained_host(&mut self) -> Vec<Bytes>

The host memory the window’s recorded copies read from, taken as it closes — onto the graph when it seals, or to be dropped when it does not, since a recording that never becomes a graph never runs them.

Source

pub fn take_failure(&mut self) -> Option<ServerError>

The failure that doomed this window, taken as it closes. Some means the recording is missing at least one operation and must not seal.

Source

pub fn is_recording(&self) -> bool

Whether launches on the stream are being recorded into a graph right now — the window during which a host sync would abort the capture, and during which a neighbour sharing the pooled stream is refused.

Source

pub fn is_active(&self) -> bool

Whether a capture is prepared or recording — the span over which the pooled stream is committed to one logical stream’s window.

Source

pub fn owner(&self) -> Option<StreamId>

The logical stream that opened the window, while one is open. None outside a capture, which is what distinguishes a neighbour’s operation from the owner’s.

Source

pub fn cache_mode(&self) -> CacheMode

How the metadata caches behave for this stream right now: a window pins what it builds, so a replay finds the same entries it recorded against.

Source

pub fn prepare(&mut self, owner: StreamId) -> Result<(), ServerError>

Arm the persistent pools for the warmup run; begin may open the window afterwards. A capture starts from an empty recording, so a window that was abandoned mid-flight cannot leak its buffers into the next one.

§Errors

Fails when a capture is already prepared or recording, leaving both the state and the recording untouched.

Source

pub fn begin(&mut self) -> Result<(), ServerError>

Open the window: launches from here until end are recorded rather than executed.

§Errors

Fails when no capture is prepared, or one is already recording.

Source

pub fn end(&mut self, caller: StreamId) -> Result<CaptureEnd, ServerError>

Close the window, saying whether caller owned it — see CaptureEnd. The recording survives the transition for take_recorded to collect.

§Errors

Fails when no capture is recording, leaving the state untouched.

Source

pub fn abort(&mut self)

Give up a prepared capture that never opened, restoring the stream to no-capture. Whatever it had recorded or retained goes with it.

Trait Implementations§

Source§

impl Debug for StreamCapture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StreamCapture

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more