Skip to main content

EventFence

Struct EventFence 

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

Source

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.

Source

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.

Source

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>

Source§

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

Formats the value using the given formatter. Read more
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.

Source§

fn wait(self) -> Result<(), ServerError>

Block the current thread until the device signals this fence. Read more
Source§

fn sync(self)

wait, ignoring a fault. Read more

Auto Trait Implementations§

§

impl<A> Freeze for EventFence<A>
where Event<A>: Freeze,

§

impl<A> RefUnwindSafe for EventFence<A>
where Event<A>: RefUnwindSafe,

§

impl<A> Send for EventFence<A>
where Event<A>: Send,

§

impl<A> Sync for EventFence<A>
where Event<A>: Sync,

§

impl<A> Unpin for EventFence<A>
where Event<A>: Unpin,

§

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