pub trait CudaEventWaiter: SyncWaiter {
// Required method
fn wait_on_foreign_stream(
&self,
foreign_stream: *mut c_void,
) -> Result<(), Error>;
}Expand description
CUDA-event-specific extension trait for the
SyncPoint::CudaEvent variant. Supertrait of SyncWaiter so a
CudaEventWaiter always satisfies the generic SyncPoint::wait
dispatch path; adds the CUDA-only wait_on_foreign_stream extension
method that cross-API bridges downcast to via
SyncWaiter::as_any.
§Drop discipline
Implementations MUST push the event’s owning CUcontext before
calling cuEventDestroy_v2, and MUST pop iff the push succeeded
(pop-without-push would silently consume whatever the calling
thread had on top of its context stack). cuEventDestroy_v2
requires the owning context to still exist; the push is defensive
against driver-internal cleanup paths that probe cuCtxGetCurrent
and emit confusing diagnostics when no context is current.
§Cross-context wait
cuEventRecord is strict-same-context — a CUevent cannot be
recorded against a stream from a different CUcontext. But
cuStreamWaitEvent is cross-context (NVIDIA Driver API contract).
wait_on_foreign_stream is the cross-context wait entry point:
the consumer’s CUDA stream may live in a different CUcontext
than the event, and the waiter issues cuStreamWaitEvent so the
foreign stream gates on this event’s completion without a CPU
bounce.
A waiter backed by the CUDA driver API implements this trait concretely; this trait only defines the contract.
Required Methods§
Sourcefn wait_on_foreign_stream(
&self,
foreign_stream: *mut c_void,
) -> Result<(), Error>
fn wait_on_foreign_stream( &self, foreign_stream: *mut c_void, ) -> Result<(), Error>
Issue cuStreamWaitEvent(foreign_stream, self.event, 0) so
foreign_stream gates on this event’s completion. The stream
may belong to a different CUcontext than the event’s owning
context — cuStreamWaitEvent is cross-context per the NVIDIA
Driver API.
foreign_stream is a raw CUstream pointer (the null pointer
resolves to the calling thread’s default stream).
Returns Error::NotSupported if the CUDA driver loader is
unavailable or the wait dispatch returns a driver error; the
concrete error wording is implementation-defined.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".