pub struct StreamCaptureState { /* private fields */ }Expand description
Where a stream sits in the graph-capture lifecycle, and the only thing
allowed to move it. Capture is a strict NoCapture → Prepare → Capture → NoCapture progression, driven by prepare,
begin and end; each rejects an out-of-order
call, so a capture can never start unprepared and two captures can never
overlap on one stream.
§One capture, one logical stream
The three calls have to come from the same logical stream. The window is
opened on the pooled stream that logical stream folds onto, and the launches
in between are recorded there — so a caller whose StreamId changes
half-way (an .await resuming on another thread under the default
PerThread policy, without set_stream pinning) has already split its
recording across two backend streams before it ever reaches end. Pin the
stream around a capture; end treats a caller that is not the
owner as a window nobody is coming back for, and abandons it.
The transitions live here rather than in each backend server because the rule is the same on every one of them — a backend supplies only the work a transition brackets (arming its pools, opening the driver’s capture), never the ordering rule itself.
§What the neighbours pay
The window is held on a pooled stream, and logical streams fold onto those
with id % max_streams — so a capture costs every logical stream sharing
that slot, not just the one recording. On a software-graph backend a
neighbour’s read, sync or profile is refused outright for the duration, and
its write is refused with the refusal landing on its own destinations; on a
hardware-graph backend a
neighbour’s fenced flush is deferred until the window closes. None of that
is attributed to the capture, because a refusal is not a failure of the
capture: the neighbour asked for something this slot cannot do right now.
It is a real cost of folding, and the reason a capture is worth pinning to a stream nothing else is scheduled on.
Both active states carry the logical stream that opened the capture. Several logical streams share one backend stream, so “the capture owns this stream for its window” only holds if the window remembers whose it is: an error raised inside it dooms the capture, not whichever neighbour happens to be using the slot.
Implementations§
Source§impl StreamCaptureState
impl StreamCaptureState
Sourcepub fn is_recording(&self) -> bool
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 (or is rejected by) the capture.
Sourcepub fn is_preparing(&self) -> bool
pub fn is_preparing(&self) -> bool
Whether the warmup run is under way: prepared, and the window not open yet.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Whether a capture is prepared or recording — the whole window during which the stream is not free to serve other work.
Sourcepub fn owner(&self) -> Option<StreamId>
pub fn owner(&self) -> Option<StreamId>
The logical stream this capture belongs to, None outside a window.
Sourcepub fn device(&self) -> &CaptureStatus
pub fn device(&self) -> &CaptureStatus
The captures of the whole device this stream belongs to, this one included.
Sourcepub fn prepare(&mut self, owner: StreamId) -> Result<(), ServerError>
pub fn prepare(&mut self, owner: StreamId) -> Result<(), ServerError>
NoCapture → Prepare, for graph_prepare. Call before arming the
pools; the caller owns the arming, this owns the rule that it happens
exactly once per capture.
§Errors
Fails when a capture is already prepared or already recording on this
stream, leaving the state untouched — two captures may never overlap on
one stream. The caller can retry after end_capture.
Sourcepub fn begin(&mut self) -> Result<(), ServerError>
pub fn begin(&mut self) -> Result<(), ServerError>
Prepare → Capture, for begin_capture. Call before the work that
opens the window (ending the priming phase, starting the driver’s
capture) so a rejected call cannot run any of it: on a stream that is
already recording, a drop-queue flush issued on the way to the rejection
would abort the live capture.
Since the state moves before that work, a backend whose window fails to
open must undo it with abort.
§Errors
Fails when prepare has not run — the pools have to
be warmed by a warmup run first — or when a capture is already
recording. The state is left untouched.
Sourcepub fn end(&mut self, caller: StreamId) -> Result<CaptureEnd, ServerError>
pub fn end(&mut self, caller: StreamId) -> Result<CaptureEnd, ServerError>
Capture → NoCapture, for end_capture. Call before closing the
window, so the stream leaves capture state even if sealing the graph
then fails — a backend that returned an error with the state still set
would wedge the stream in capture mode forever.
A caller that does not own the window closes it all the same, as
CaptureEnd::Abandoned: only the owner may seal a capture, but
leaving the window open until an owner that may never come back closes
it would wedge the pooled stream for every logical stream sharing it —
see CaptureEnd for why that is the lesser of the two.
§Errors
Fails when no capture is recording (nothing prepared or started, or the
capture already ended), leaving the state untouched — a stray
end_capture must not close a window that was never opened.
Sourcepub fn abort(&mut self)
pub fn abort(&mut self)
Return to NoCapture from anywhere, for the failure path of a
transition’s own work: the window never opened, so the stream must be
left fully usable and re-capturable rather than stuck preparing
forever. Unlike end this asserts
nothing, because the state it is recovering from is precisely the one
that could not be completed.
Trait Implementations§
Source§impl Debug for StreamCaptureState
impl Debug for StreamCaptureState
Source§impl Drop for StreamCaptureState
impl Drop for StreamCaptureState
Auto Trait Implementations§
impl Freeze for StreamCaptureState
impl RefUnwindSafe for StreamCaptureState
impl Send for StreamCaptureState
impl Sync for StreamCaptureState
impl Unpin for StreamCaptureState
impl UnsafeUnpin for StreamCaptureState
impl UnwindSafe for StreamCaptureState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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