Struct blaze_rs::event::Event

source ·
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 Event<Noop>

source

pub fn new_noop(inner: RawEvent) -> Self

Creates a new noop event.

source

pub fn set_consumer<C: Consumer>(self, consumer: C) -> Event<C>

Adds a consumer to a noop event

source§

impl<'a, T: 'a> Event<PhantomData<T>>

source

pub fn new_phantom(inner: RawEvent) -> Self

Creates a new phantom event.

source§

impl<C: Consumer> Event<C>

source

pub fn new(inner: RawEvent, consumer: C) -> Self

Creates a new event with the specified consumer.

source

pub fn into_parts(self) -> (RawEvent, C)

Consumes the event and returns it’s inner parts

source

pub fn as_raw(&self) -> &RawEvent

Returns a reference to the underlying RawEvent.

source

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

source

pub unsafe fn take_consumer(self) -> (C, NoopEvent)

Takes the current event’s Consumer, leaving a Noop in it’s place.

Safety

This method is unsafe because the Consumer may have implementation details needed for the general safety of the event.

source

pub fn abortable(self) -> Result<(AbortableEvent<C>, AbortHandle)>

Available on crate feature 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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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>

source

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>

source

pub fn flatten(self) -> Result<FlattenEvent<N>>where C: 'static + Send + Sync, N: 'static + Send,

Available on crate feature cl1_1 only.
source

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,

Available on crate feature cl1_1 only.
source

pub fn flatten_join(self) -> Result<N::Output>

source

pub async fn flatten_join_async(self) -> Result<N::Output>where C: Unpin, N: Unpin,

Available on crate feature futures only.
source§

impl<'a, C: 'a + Consumer> Event<C>

source

pub fn into_dyn(self) -> DynEvent<'a, C::Output>where C: Send,

Turn’s the event into a DynEvent. A DynEvent contains a boxed dynamic consumer that can be shared between threads.

source

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.

source

pub fn join(self) -> Result<C::Output>

Blocks the current thread until the event has completed, consuming it and returning it’s value.

source

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.

source

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.

source

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.

source

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.

source

pub fn join_async(self) -> Result<EventWait<C>>where C: Unpin,

Available on crate feature futures only.

Returns a future that waits for the event to complete without blocking.

source

pub fn join_all<I: IntoIterator<Item = Self>>( iter: I ) -> Result<JoinAllEvent<C>>

Available on crate feature 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.

source

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.

source

pub fn join_sized_blocking<const N: usize>( iter: [Self; N] ) -> Result<[C::Output; N]>

Available on crate feature 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>

source

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,

source

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,

source

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,

source

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,

source

pub fn on_submit<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>( &self, f: F ) -> Result<CallbackHandle<T>>

source

pub fn on_run<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>( &self, f: F ) -> Result<CallbackHandle<T>>

source

pub fn on_complete<T: 'static + Send, F: 'static + Send + Sync + FnOnce(RawEvent, Result<EventStatus>) -> T>( &self, f: F ) -> Result<CallbackHandle<T>>

source

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

source

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

source

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

source

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

source

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

source

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.

source

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.

source

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.

source

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.

source

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

source

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

source

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

source

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

source

pub fn id(&self) -> cl_event

source

pub unsafe fn retain(&self) -> Result<()>

source

pub fn join_by_ref(&self) -> Result<()>

source

pub fn ty(&self) -> Result<CommandType>

Returns the event’s type

source

pub fn status(&self) -> Result<EventStatus>

Returns the event’s current status

source

pub fn command_queue(&self) -> Result<Option<RawCommandQueue>>

Returns the event’s underlying command queue

source

pub fn reference_count(&self) -> Result<u32>

source

pub fn raw_context(&self) -> Result<RawContext>

Available on crate feature cl1_1 only.

Return the context associated with event.

source

pub fn profiling_nanos(&self) -> Result<ProfilingInfo<u64>>

Returns this event’s profiling info in u64 nanoseconds.

source

pub fn profiling_time(&self) -> Result<ProfilingInfo<SystemTime>>

Returns this event’s profiling info in SystemTime.

source

pub fn duration(&self) -> Result<Duration>

Returns the time elapsed between the event’s start and end.

source

pub fn is_queued(&self) -> bool

Returns true if the status of the event is EventStatus::Queued or an error, false otherwise.

source

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.

source

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.

source

pub fn has_completed(&self) -> bool

Returns true if the status of the event is EventStatus::Complete or an error, false otherwise.

source

pub fn get_info<T: Copy>(&self, id: cl_event_info) -> Result<T>

source

pub fn on_submit<T: 'static + Send>( &self, f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T ) -> Result<CallbackHandle<T>>

Available on crate feature cl1_1 only.
source

pub fn on_run<T: 'static + Send>( &self, f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T ) -> Result<CallbackHandle<T>>

Available on crate feature cl1_1 only.
source

pub fn on_complete<T: 'static + Send>( &self, f: impl 'static + Send + FnOnce(RawEvent, Result<EventStatus>) -> T ) -> Result<CallbackHandle<T>>

Available on crate feature cl1_1 only.
source

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

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.

source

pub fn on_submit_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>

Available on crate feature cl1_1 only.

Adds a callback function that will be executed when the event is submitted.

source

pub fn on_run_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>

Available on crate feature cl1_1 only.

Adds a callback function that will be executed when the event starts running.

source

pub fn on_complete_silent( &self, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>

Available on crate feature cl1_1 only.

Adds a callback function that will be executed when the event completes.

source

pub fn on_status_silent( &self, status: EventStatus, f: impl 'static + FnOnce(RawEvent, Result<EventStatus>) + Send ) -> Result<()>

Available on crate feature 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.

source

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

Available on crate feature cl1_1 only.
source

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

Available on crate feature cl1_1 only.
source

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

Available on crate feature cl1_1 only.
source

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

Available on crate feature cl1_1 only.

Trait Implementations§

source§

impl<C: Clone> Clone for Event<C>

source§

fn clone(&self) -> Event<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C: Debug> Debug for Event<C>

source§

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

Formats the value using the given formatter. Read more
source§

impl<C: Consumer> Deref for Event<C>

§

type Target = RawEvent

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Into<Event<Noop>> for RawEvent

source§

fn into(self) -> NoopEvent

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for Event<C>where C: RefUnwindSafe,

§

impl<C> Send for Event<C>where C: Send,

§

impl<C> Sync for Event<C>where C: Sync,

§

impl<C> Unpin for Event<C>where C: Unpin,

§

impl<C> UnwindSafe for Event<C>where C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.