pub struct EventFence<A: EventApi> { /* private fields */ }Expand description
An event recorded on a stream and handed out, so a caller can wait for that stream’s work from outside the server.
The server sits behind a mutex or a channel, so a synchronize that blocked while holding it would stall every other logical stream too. Recording an event costs the host nothing: the server records one and returns, and whoever holds the fence waits on its own time.
Named for the trait it is not: memory_management::drop_queue::Fence is the
contract, and this is the implementation of it that a device event gives
you. Backends alias it back to Fence for their own call sites. Named in
prose rather than linked because that trait is multi_threading-only while
this type is not — the fence itself is two driver calls and wants no
threads.
Its event is created and destroyed outright rather than recycled through the
pool an EventProfiler keeps: a fence is raised from
StreamBackend::flush, which is handed a stream and nothing else, so there
is no pool in reach without threading one through that trait. Pool these too
once something else needs the same argument.
Implementations§
Source§impl<A: EventApi> EventFence<A>
impl<A: EventApi> EventFence<A>
Sourcepub fn new(stream: A::Stream) -> Self
pub fn new(stream: A::Stream) -> Self
Record a fence at the current position of stream.
§Panics
A fence that never recorded cannot be waited on, and every caller takes one by value expecting to be able to. There is no useful weaker answer than failing here.
Sourcepub fn wait_sync(self) -> Result<(), ServerError>
pub fn wait_sync(self) -> Result<(), ServerError>
Block until the device has reached this fence, so everything enqueued on its stream beforehand is done.
§Errors
The fault the wait reveals, when the stream itself failed.
Sourcepub fn wait_async(self, stream: A::Stream)
pub fn wait_async(self, stream: A::Stream)
Make stream wait for this fence on the device, so work queued on it
afterwards runs behind the fenced stream’s. Does not block the host.
§Panics
A refused dependency would let stream run ahead of work it must
follow, which is a wrong answer rather than a slow one.
Trait Implementations§
Source§impl<A: EventApi> Debug for EventFence<A>
impl<A: EventApi> Debug for EventFence<A>
Source§impl<A: EventApi> Fence for EventFence<A>
Available on multi_threading only.The drop queue is where a fence pays off — a freed host buffer waits on one
rather than on the server — and it is multi_threading-only, so the impl is
too. Everything above it is the same fence either way.
impl<A: EventApi> Fence for EventFence<A>
multi_threading only.The drop queue is where a fence pays off — a freed host buffer waits on one
rather than on the server — and it is multi_threading-only, so the impl is
too. Everything above it is the same fence either way.
Auto Trait Implementations§
impl<A> Freeze for EventFence<A>
impl<A> RefUnwindSafe for EventFence<A>where
Event<A>: RefUnwindSafe,
impl<A> Send for EventFence<A>
impl<A> Sync for EventFence<A>
impl<A> Unpin for EventFence<A>
impl<A> UnsafeUnpin for EventFence<A>where
Event<A>: UnsafeUnpin,
impl<A> UnwindSafe for EventFence<A>where
Event<A>: UnwindSafe,
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