pub struct Event<C> { /* private fields */ }Expand description
An event with a consumer that will be executed on the completion of the former.
When using OpenCL 1.0, the event will also contain a sender that will send the event’s callbacks,
(like on_complete) to a different thread to be executed acordingly.
Implementations§
source§impl<'a, T: 'a> Event<PhantomData<T>>
impl<'a, T: 'a> Event<PhantomData<T>>
sourcepub fn new_phantom(inner: RawEvent) -> Self
pub fn new_phantom(inner: RawEvent) -> Self
Creates a new phantom event.
source§impl<C: Consumer> Event<C>
impl<C: Consumer> Event<C>
sourcepub fn new(inner: RawEvent, consumer: C) -> Self
pub fn new(inner: RawEvent, consumer: C) -> Self
Creates a new event with the specified consumer.
sourcepub fn into_parts(self) -> (RawEvent, C)
pub fn into_parts(self) -> (RawEvent, C)
Consumes the event and returns it’s inner parts
sourcepub fn map_consumer<'a, N: 'a + Consumer, F: FnOnce(C) -> N>(
this: Self,
f: F
) -> Event<N>where
C: 'a,
pub fn map_consumer<'a, N: 'a + Consumer, F: FnOnce(C) -> N>( this: Self, f: F ) -> Event<N>where C: 'a,
Maps the current event consumer to a new one
sourcepub unsafe fn take_consumer(self) -> (C, NoopEvent)
pub unsafe fn take_consumer(self) -> (C, NoopEvent)
sourcepub fn abortable(self) -> Result<(AbortableEvent<C>, AbortHandle)>
Available on crate feature cl1_1 only.
pub fn abortable(self) -> Result<(AbortableEvent<C>, AbortHandle)>
cl1_1 only.Makes the current event abortable.
When aborted, the event will not be unqueued from the OpenCL queue, rather the Blaze event will return early with a result of Ok(None).
If the event isn’t aborted before it’s completion, it will return Ok(Some(value)) in case of success, and Err(error) if it fails.
sourcepub fn specific<'a>(self) -> SpecificEvent<'a, C>where
C: 'a,
pub fn specific<'a>(self) -> SpecificEvent<'a, C>where C: 'a,
Returns an event with the consumer restricted to a specified lifetime.
The original consumer must have a lifetime greater or equal to the new one.
sourcepub fn map<F: FnOnce(C::Output) -> U, U>(
self,
f: F
) -> MapEvent<C::Output, C, F>
pub fn map<F: FnOnce(C::Output) -> U, U>( self, f: F ) -> MapEvent<C::Output, C, F>
Returns an event that maps the result of the previous event.
sourcepub fn try_map<F: FnOnce(C::Output) -> Result<U>, U>(
self,
f: F
) -> TryMapEvent<C::Output, C, F>
pub fn try_map<F: FnOnce(C::Output) -> Result<U>, U>( self, f: F ) -> TryMapEvent<C::Output, C, F>
Returns an event that maps the result of the previous event, flattening the result.
sourcepub fn catch_unwind(self) -> CatchUnwindEvent<C>where
C: UnwindSafe,
pub fn catch_unwind(self) -> CatchUnwindEvent<C>where C: UnwindSafe,
Returns an event that will catch the consumer’s panic.
Note that this method requires the current consumer to be UnwindSafe.
If this requirement proves bothersome, you can use assert_unwind_safe.
sourcepub fn assert_catch_unwind(self) -> AssertCatchUnwindEvent<C>
pub fn assert_catch_unwind(self) -> AssertCatchUnwindEvent<C>
Returns an event that will catch the consumer’s panic.
Note that this method does not requires the current consumer to be UnwindSafe, as it’s wrapped with AssertUnwindSafe.
If the consumer is known to be UnwindSafe, the catch_unwind method is preferable.
sourcepub fn inspect<F: FnOnce(&C::Output)>(self, f: F) -> InspectEvent<C, F>
pub fn inspect<F: FnOnce(&C::Output)>(self, f: F) -> InspectEvent<C, F>
Returns an event that will inspect it’s parent’s return value before completing.
sourcepub fn taking<T>(self, t: T) -> TakingEvent<C, T>
pub fn taking<T>(self, t: T) -> TakingEvent<C, T>
Returns an event that will consume t when consumed or dropped.
The event still returns the same output the previous consumer provided.
source§impl<T, C: Consumer<Output = Result<T>>> Event<C>
impl<T, C: Consumer<Output = Result<T>>> Event<C>
sourcepub fn flatten_result(self) -> FlattenResultEvent<C>
pub fn flatten_result(self) -> FlattenResultEvent<C>
Returns an event that flattens the result of it’s parent.
source§impl<N: Consumer, C: Consumer<Output = Event<N>>> Event<C>
impl<N: Consumer, C: Consumer<Output = Event<N>>> Event<C>
pub fn flatten(self) -> Result<FlattenEvent<N>>where C: 'static + Send + Sync, N: 'static + Send,
cl1_1 only.pub fn flatten_scoped<'scope, 'env, Ctx: Context>( self, scope: &'scope Scope<'scope, 'env, Ctx> ) -> Result<FlattenScopedEvent<'scope, N>>where C: 'scope + Send, N: 'scope + Send,
cl1_1 only.pub fn flatten_join(self) -> Result<N::Output>
pub async fn flatten_join_async(self) -> Result<N::Output>where C: Unpin, N: Unpin,
futures only.source§impl<'a, C: 'a + Consumer> Event<C>
impl<'a, C: 'a + Consumer> Event<C>
sourcepub fn into_local(self) -> DynLocalEvent<'a, C::Output>
pub fn into_local(self) -> DynLocalEvent<'a, C::Output>
Turn’s the event into a DynLocalEvent.
A DynLocalEvent contains a boxed dynamic consumer that cannot be shared between threads.
sourcepub fn join(self) -> Result<C::Output>
pub fn join(self) -> Result<C::Output>
Blocks the current thread until the event has completed, consuming it and returning it’s value.
sourcepub fn join_with_nanos(self) -> Result<(C::Output, ProfilingInfo<u64>)>
pub fn join_with_nanos(self) -> Result<(C::Output, ProfilingInfo<u64>)>
Blocks the current thread until the event has completes, consuming it and returning it’s value, alongside it’s profiling info in nanoseconds.
sourcepub fn join_with_time(self) -> Result<(C::Output, ProfilingInfo<SystemTime>)>
pub fn join_with_time(self) -> Result<(C::Output, ProfilingInfo<SystemTime>)>
Blocks the current thread until the event has completes, consuming it and returning it’s value, alongside it’s profiling info in SystemTime.
sourcepub fn join_with_duration(self) -> Result<(C::Output, Duration)>
pub fn join_with_duration(self) -> Result<(C::Output, Duration)>
Blocks the current thread until the event has completes, consuming it and returning it’s value, alongside it’s duration.
sourcepub fn join_unwrap(self) -> C::Output
pub fn join_unwrap(self) -> C::Output
Blocks the current thread util the event has completed, consuming it and returning it’s value if it completed correctly, and panicking otherwise.
sourcepub fn join_async(self) -> Result<EventWait<C>>where
C: Unpin,
Available on crate feature futures only.
pub fn join_async(self) -> Result<EventWait<C>>where C: Unpin,
futures only.Returns a future that waits for the event to complete without blocking.
sourcepub fn join_all<I: IntoIterator<Item = Self>>(
iter: I
) -> Result<JoinAllEvent<C>>
Available on crate feature cl1_1 only.
pub fn join_all<I: IntoIterator<Item = Self>>( iter: I ) -> Result<JoinAllEvent<C>>
cl1_1 only.Returns an event that completes when all the events inside iter complete (or one of them fails).
The new event will return it’s parents results inside a Vec, in the same order they were in the iterator.
Note that if the iterator is empty, this funtion will return an error.
sourcepub fn join_all_blocking<I: IntoIterator<Item = Self>>(
iter: I
) -> Result<Vec<C::Output>>
pub fn join_all_blocking<I: IntoIterator<Item = Self>>( iter: I ) -> Result<Vec<C::Output>>
Blocks the current thread until all the events in the iterator have completed, returning their values inside a Vec.
The order of the values in the result is the same as their parents inside the iterator.
sourcepub fn join_sized_blocking<const N: usize>(
iter: [Self; N]
) -> Result<[C::Output; N]>
Available on crate feature nightly only.
pub fn join_sized_blocking<const N: usize>( iter: [Self; N] ) -> Result<[C::Output; N]>
nightly only.Blocks the current thread until all the events in the array have completed, returning their values in a new array. The order of the values in the result is the same as their parents inside the iterator.
source§impl<C: Consumer> Event<C>
impl<C: Consumer> Event<C>
pub fn then<T: 'static + Send, F: 'static + Send + Sync + FnOnce(C::Output) -> T>( self, f: F ) -> Result<CallbackHandle<Result<T>>>where C: 'static + Send + Sync,
pub fn then_scoped<'scope, 'env, T: 'scope + Send, F: 'scope + Send + Sync + FnOnce(C::Output) -> T, Ctx: Context>( self, scope: &'scope Scope<'scope, 'env, Ctx>, f: F ) -> Result<ScopedCallbackHandle<'scope, Result<T>>>where C: 'scope + Send,
pub fn then_result<T: 'static + Send, F: 'static + Send + Sync + FnOnce(Result<C::Output>) -> T>( self, f: F ) -> Result<CallbackHandle<T>>where C: 'static + Send + Sync,
pub fn then_result_scoped<'scope, 'env, T: 'scope + Send, F: 'scope + Send + FnOnce(Result<C::Output>) -> T, Ctx: Context>( self, scope: &'scope Scope<'scope, 'env, Ctx>, f: F ) -> Result<ScopedCallbackHandle<'scope, T>>where C: 'scope + Send,
pub fn on_submit<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>( &self, f: F ) -> Result<CallbackHandle<T>>
pub fn on_run<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>( &self, f: F ) -> Result<CallbackHandle<T>>
pub fn on_complete<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>( &self, f: F ) -> Result<CallbackHandle<T>>
sourcepub fn on_status<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>(
&self,
status: EventStatus,
f: F
) -> Result<CallbackHandle<T>>
pub fn on_status<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>( &self, status: EventStatus, f: F ) -> Result<CallbackHandle<T>>
TODO DOC
pub fn on_submit_scoped<'scope, 'env, T: 'scope + Send, F: 'scope + Send + FnOnce(RawEvent, Result<EventStatus>) -> T, Ctx: Context>( &'env self, scope: &'scope Scope<'scope, 'env, Ctx>, f: F ) -> Result<ScopedCallbackHandle<'scope, T>>
pub fn on_run_scoped<'scope, 'env, T: 'scope + Send, F: 'scope + Send + FnOnce(RawEvent, Result<EventStatus>) -> T, Ctx: Context>( &'env self, scope: &'scope Scope<'scope, 'env, Ctx>, f: F ) -> Result<ScopedCallbackHandle<'scope, T>>
pub fn on_complete_scoped<'scope, 'env, T: 'scope + Send, F: 'scope + Send + FnOnce(RawEvent, Result<EventStatus>) -> T, Ctx: Context>( &'env self, scope: &'scope Scope<'scope, 'env, Ctx>, f: F ) -> Result<ScopedCallbackHandle<'scope, T>>
sourcepub fn on_status_scoped<'scope, 'env, T: 'scope + Send, F: 'scope + Send + FnOnce(RawEvent, Result<EventStatus>) -> T, Ctx: Context>(
&'env self,
scope: &'scope Scope<'scope, 'env, Ctx>,
status: EventStatus,
f: F
) -> Result<ScopedCallbackHandle<'scope, T>>
pub fn on_status_scoped<'scope, 'env, T: 'scope + Send, F: 'scope + Send + FnOnce(RawEvent, Result<EventStatus>) -> T, Ctx: Context>( &'env self, scope: &'scope Scope<'scope, 'env, Ctx>, status: EventStatus, f: F ) -> Result<ScopedCallbackHandle<'scope, T>>
TODO DOCS
sourcepub fn on_submit_silent(
&self,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync
) -> Result<()>
pub fn on_submit_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync ) -> Result<()>
Adds a callback function that will be executed when the event is submitted.
sourcepub fn on_run_silent(
&self,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync
) -> Result<()>
pub fn on_run_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync ) -> Result<()>
Adds a callback function that will be executed when the event starts running.
sourcepub fn on_complete_silent(
&self,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync
) -> Result<()>
pub fn on_complete_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync ) -> Result<()>
Adds a callback function that will be executed when the event completes.
sourcepub fn on_status_silent(
&self,
status: EventStatus,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync
) -> Result<()>
pub fn on_status_silent( &self, status: EventStatus, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send + Sync ) -> Result<()>
Registers a user callback function for a specific command execution status.
The registered callback function will be called when the execution status of command associated with event changes to an execution status equal to or past the status specified by status.
Each call to Event::on_status registers the specified user callback function on a callback stack associated with event. The order in which the registered user callback functions are called is undefined.
All callbacks registered for an event object must be called before the event object is destroyed. Callbacks should return promptly.
Behavior is undefined when calling expensive system routines, OpenCL APIs to create contexts or command-queues, or blocking OpenCL APIs in an event callback. Rather than calling a blocking OpenCL API in an event callback, applications may call a non-blocking OpenCL API, then register a completion callback for the non-blocking OpenCL API with the remainder of the work.
Because commands in a command-queue are not required to begin execution until the command-queue is flushed, callbacks that enqueue commands on a command-queue should either call RawCommandQueue::flush on the queue before returning, or arrange for the command-queue to be flushed later.
pub unsafe fn on_submit_raw( &self, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
pub unsafe fn on_run_raw( &self, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
pub unsafe fn on_complete_raw( &self, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
pub unsafe fn on_status_raw( &self, status: EventStatus, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
Methods from Deref<Target = RawEvent>§
pub fn id(&self) -> cl_event
pub unsafe fn retain(&self) -> Result<()>
pub fn join_by_ref(&self) -> Result<()>
sourcepub fn ty(&self) -> Result<CommandType>
pub fn ty(&self) -> Result<CommandType>
Returns the event’s type
sourcepub fn status(&self) -> Result<EventStatus>
pub fn status(&self) -> Result<EventStatus>
Returns the event’s current status
sourcepub fn command_queue(&self) -> Result<Option<RawCommandQueue>>
pub fn command_queue(&self) -> Result<Option<RawCommandQueue>>
Returns the event’s underlying command queue
pub fn reference_count(&self) -> Result<u32>
sourcepub fn raw_context(&self) -> Result<RawContext>
Available on crate feature cl1_1 only.
pub fn raw_context(&self) -> Result<RawContext>
cl1_1 only.Return the context associated with event.
sourcepub fn profiling_nanos(&self) -> Result<ProfilingInfo<u64>>
pub fn profiling_nanos(&self) -> Result<ProfilingInfo<u64>>
Returns this event’s profiling info in u64 nanoseconds.
sourcepub fn profiling_time(&self) -> Result<ProfilingInfo<SystemTime>>
pub fn profiling_time(&self) -> Result<ProfilingInfo<SystemTime>>
Returns this event’s profiling info in SystemTime.
sourcepub fn duration(&self) -> Result<Duration>
pub fn duration(&self) -> Result<Duration>
Returns the time elapsed between the event’s start and end.
sourcepub fn is_queued(&self) -> bool
pub fn is_queued(&self) -> bool
Returns true if the status of the event is EventStatus::Queued or an error, false otherwise.
sourcepub fn has_submited(&self) -> bool
pub fn has_submited(&self) -> bool
Returns true if the status of the event is EventStatus::Submitted, EventStatus::Running, EventStatus::Complete or an error, false otherwise.
sourcepub fn has_started_running(&self) -> bool
pub fn has_started_running(&self) -> bool
Returns true if the status of the event is EventStatus::Running, EventStatus::Complete or an error, false otherwise.
sourcepub fn has_completed(&self) -> bool
pub fn has_completed(&self) -> bool
Returns true if the status of the event is EventStatus::Complete or an error, false otherwise.
pub fn get_info<T: Copy>(&self, id: cl_event_info) -> Result<T>
pub fn on_submit<T: 'static + Send>( &self, f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T ) -> Result<CallbackHandle<T>>
cl1_1 only.pub fn on_run<T: 'static + Send>( &self, f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T ) -> Result<CallbackHandle<T>>
cl1_1 only.pub fn on_complete<T: 'static + Send>( &self, f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T ) -> Result<CallbackHandle<T>>
cl1_1 only.sourcepub fn on_status<T: 'static + Send>(
&self,
status: EventStatus,
f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T
) -> Result<CallbackHandle<T>>
Available on crate feature cl1_1 only.
pub fn on_status<T: 'static + Send>( &self, status: EventStatus, f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T ) -> Result<CallbackHandle<T>>
cl1_1 only.Adds a callback function that will be executed when the event reaches the specified status.
Unlike on_status_silent, this method returns a CallbackHandle that allows to wait for the callcack to execute and getting its result.
sourcepub fn on_submit_silent(
&self,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send
) -> Result<()>
Available on crate feature cl1_1 only.
pub fn on_submit_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>
cl1_1 only.Adds a callback function that will be executed when the event is submitted.
sourcepub fn on_run_silent(
&self,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send
) -> Result<()>
Available on crate feature cl1_1 only.
pub fn on_run_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>
cl1_1 only.Adds a callback function that will be executed when the event starts running.
sourcepub fn on_complete_silent(
&self,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send
) -> Result<()>
Available on crate feature cl1_1 only.
pub fn on_complete_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>
cl1_1 only.Adds a callback function that will be executed when the event completes.
sourcepub fn on_status_silent(
&self,
status: EventStatus,
f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send
) -> Result<()>
Available on crate feature cl1_1 only.
pub fn on_status_silent( &self, status: EventStatus, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>
cl1_1 only.Registers a user callback function for a specific command execution status.
The registered callback function will be called when the execution status of command associated with event changes to an execution status equal to or past the status specified by status.
Each call to Event::on_status registers the specified user callback function on a callback stack associated with event. The order in which the registered user callback functions are called is undefined.
All callbacks registered for an event object must be called before the event object is destroyed. Callbacks should return promptly.
Behavior is undefined when calling expensive system routines, OpenCL APIs to create contexts or command-queues, or blocking OpenCL APIs in an event callback. Rather than calling a blocking OpenCL API in an event callback, applications may call a non-blocking OpenCL API, then register a completion callback for the non-blocking OpenCL API with the remainder of the work.
Because commands in a command-queue are not required to begin execution until the command-queue is flushed, callbacks that enqueue commands on a command-queue should either call RawCommandQueue::flush on the queue before returning, or arrange for the command-queue to be flushed later.
pub unsafe fn on_submit_raw( &self, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
cl1_1 only.pub unsafe fn on_run_raw( &self, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
cl1_1 only.pub unsafe fn on_complete_raw( &self, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
cl1_1 only.pub unsafe fn on_status_raw( &self, status: EventStatus, f: unsafe extern "C" fn(event: cl_event, event_command_status: cl_int, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>
cl1_1 only.