Struct ocl::Event

source ·
#[repr(C)]
pub struct Event(/* private fields */);
Expand description

An event representing a command or user created event.

Implementations§

source§

impl Event

source

pub fn empty() -> Event

Creates a new, empty (null) event which must be filled by a command, associating the event with it.

source

pub fn user<C: ClContextPtr>(context: C) -> OclResult<Event>

Creates a new, empty event which must be filled by a newly initiated command, associating the event with it.

source

pub fn is_empty(&self) -> bool

Returns true if this event is ‘empty’ and has not yet been associated with a command.

source

pub fn set_unpark_callback(&self) -> OclResult<()>

Sets a callback function to trigger upon completion of this event which will unpark the current task.

To be used within the context of a futures task.

§Panics

This function will panic if a task is not currently being executed. That is, this method can be dangerous to call outside of an implementation of poll.

source

pub unsafe fn register_event_relay(&self, user_event: Event) -> OclResult<()>

Registers a user event to have its status set to complete (CommandExecutionStatus::Complete) immediately upon completion of this event.

§Deadlocks

Due to the nature of OpenCL queue implementations, care must be taken when using this function. OpenCL queue deadlocks may occur.

OpenCL queues generally use one thread per queue for the purposes of callbacks, etc. As a rule of thumb, ensure that any OpenCL commands preceding the causation/source event (self) are in a separate queue from any commands with the dependent/target event (user_event).

§Safety

The caller must ensure that user_event was created with Event::user() and that it’s status is CommandExecutionStatus::Submitted (the default upon creation).

source

pub fn info(&self, info_kind: EventInfo) -> OclResult<EventInfoResult>

Returns info about the event.

source

pub fn profiling_info( &self, info_kind: ProfilingInfo ) -> OclResult<ProfilingInfoResult>

Returns info about the event.

source

pub fn queue_core(&self) -> OclResult<CommandQueueCore>

Returns this event’s associated command queue.

source

pub fn as_core(&self) -> &EventCore

Returns a reference to the core pointer wrapper, usable by functions in the core module.

source

pub fn into_raw(self) -> cl_event

Consumes the Event, returning the wrapped cl_event pointer.

To avoid a memory leak the pointer must be converted back to an Event using Event::from_raw.

source

pub unsafe fn from_raw(ptr: cl_event) -> Event

Constructs an Event from a raw cl_event pointer.

The raw pointer must have been previously returned by a call to a Event::into_raw.

Methods from Deref<Target = EventCore>§

source

pub fn set_complete(&self) -> Result<(), Error>

Sets this user created event to CommandExecutionStatus::Complete.

Will return an error if this event is not a ‘user’ event (created with ::user()).

source

pub fn is_complete(&self) -> Result<bool, Error>

Queries the command status associated with this event and returns true if it is complete, false if incomplete or upon error.

This is the fastest possible way to determine event status.

source

pub fn wait_for(&self) -> Result<(), Error>

Causes the command queue to wait until this event is complete before returning.

source

pub fn is_null(&self) -> bool

Returns whether or not this event is associated with a command or is a user event.

source

pub fn is_valid(&self) -> bool

[FIXME]: ADD VALIDITY CHECK BY CALLING ‘_INFO’ OR SOMETHING: NULL CHECK IS NOT ENOUGH

This still leads to crazy segfaults when non-event pointers (random whatever addresses) are passed. Need better check.

source

pub unsafe fn set_callback( &self, callback_receiver: extern "C" fn(_: *mut c_void, _: i32, _: *mut c_void), user_data_ptr: *mut c_void ) -> Result<(), Error>

Sets a callback function, callback_receiver, to trigger upon completion of this event with an optional pointer to user data.

The callback function must have a signature matching: extern "C" fn (ffi::cl_event, i32, *mut libc::c_void)

§Safety

user_data must be guaranteed to still exist if and when callback_receiver is ever called.

TODO: Create a safer type wrapper for callback_receiver (using an Arc?, etc.) within ocl.

source

pub fn context(&self) -> Result<Context, Error>

Returns the Context associated with this event.

source

pub unsafe fn as_ptr_ref(&self) -> &*mut c_void

Returns an immutable reference to a pointer, do not deref and store it unless you will manage its associated reference count carefully.

§Warning

DO NOT store this pointer.

DO NOT send this pointer across threads unless you are incrementing the reference count before sending and decrementing after sending.

Use ::into_raw for these purposes. Thank you.

source

pub unsafe fn as_ptr_mut(&mut self) -> &mut *mut c_void

Returns a mutable reference to a pointer, do not deref then modify or store it unless you will manage its associated reference count carefully.

§Warning

DO NOT store this pointer.

DO NOT send this pointer across threads unless you are incrementing the reference count before sending and decrementing after sending.

Use ::into_raw for these purposes. Thank you.

Trait Implementations§

source§

impl AsRef<Event> for Event

source§

fn as_ref(&self) -> &EventCore

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'e> ClEventPtrRef<'e> for Event

source§

unsafe fn as_ptr_ref(&'e self) -> &'e cl_event

source§

impl<'a> ClNullEventPtr for &'a mut Event

source§

fn alloc_new(&mut self) -> *mut cl_event

source§

unsafe fn clone_from<E: AsRef<EventCore>>(&mut self, ev: E)

source§

impl<'a> ClWaitListPtr for &'a Event

source§

unsafe fn as_ptr_ptr(&self) -> *const cl_event

Returns a pointer to the first pointer in this list.
source§

fn count(&self) -> u32

Returns the number of items in this wait list.
source§

impl ClWaitListPtr for Event

source§

unsafe fn as_ptr_ptr(&self) -> *const cl_event

Returns a pointer to the first pointer in this list.
source§

fn count(&self) -> u32

Returns the number of items in this wait list.
source§

impl Clone for Event

source§

fn clone(&self) -> Event

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 Debug for Event

source§

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

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

impl Default for Event

source§

fn default() -> Event

Returns the “default value” for a type. Read more
source§

impl Deref for Event

§

type Target = Event

The resulting type after dereferencing.
source§

fn deref(&self) -> &EventCore

Dereferences the value.
source§

impl DerefMut for Event

source§

fn deref_mut(&mut self) -> &mut EventCore

Mutably dereferences the value.
source§

impl Display for Event

source§

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

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

impl<'a> From<&'a Event> for ClWaitListPtrEnum<'a>

source§

fn from(e: &'a Event) -> ClWaitListPtrEnum<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a mut Event> for ClNullEventPtrEnum<'a>

source§

fn from(e: &'a mut Event) -> ClNullEventPtrEnum<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a mut Event> for ClWaitListPtrEnum<'a>

source§

fn from(e: &'a mut Event) -> ClWaitListPtrEnum<'a>

Converts to this type from the input type.
source§

impl<'a> From<Event> for ClWaitListPtrEnum<'a>

source§

fn from(e: Event) -> ClWaitListPtrEnum<'a>

Converts to this type from the input type.
source§

impl From<Event> for Event

source§

fn from(ev: Event) -> EventCore

Converts to this type from the input type.
source§

impl From<Event> for Event

source§

fn from(ev: EventCore) -> Event

Converts to this type from the input type.
source§

impl<'a> From<Event> for EventArray

source§

fn from(event: Event) -> EventArray

Converts to this type from the input type.
source§

impl<'a> From<Event> for EventList

source§

fn from(event: Event) -> EventList

Converts to this type from the input type.
source§

impl Future for Event

§

type Item = ()

The type of value that this future will resolved with if it is successful.
§

type Error = Error

The type of error that this future will resolve with if it fails in a normal fashion.
source§

fn poll(&mut self) -> Poll<Self::Item, Self::Error>

Query this future to see if its value has become available, registering interest if it is not. Read more
source§

fn wait(self) -> Result<Self::Item, Self::Error>
where Self: Sized,

Block the current thread until this future is resolved. Read more
source§

fn map<F, U>(self, f: F) -> Map<Self, F>
where F: FnOnce(Self::Item) -> U, Self: Sized,

Map this future’s result to a different type, returning a new future of the resulting type. Read more
source§

fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where F: FnOnce(Self::Error) -> E, Self: Sized,

Map this future’s error to a different error, returning a new future. Read more
source§

fn from_err<E>(self) -> FromErr<Self, E>
where E: From<Self::Error>, Self: Sized,

Map this future’s error to any error implementing From for this future’s Error, returning a new future. Read more
source§

fn then<F, B>(self, f: F) -> Then<Self, B, F>
where F: FnOnce(Result<Self::Item, Self::Error>) -> B, B: IntoFuture, Self: Sized,

Chain on a computation for when a future finished, passing the result of the future to the provided closure f. Read more
source§

fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
where F: FnOnce(Self::Item) -> B, B: IntoFuture<Error = Self::Error>, Self: Sized,

Execute another future after this one has resolved successfully. Read more
source§

fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>
where F: FnOnce(Self::Error) -> B, B: IntoFuture<Item = Self::Item>, Self: Sized,

Execute another future if this one resolves with an error. Read more
source§

fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>
where B: IntoFuture<Item = Self::Item, Error = Self::Error>, Self: Sized,

Waits for either one of two futures to complete. Read more
source§

fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>
where B: IntoFuture, Self: Sized,

Waits for either one of two differently-typed futures to complete. Read more
source§

fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>
where B: IntoFuture<Error = Self::Error>, Self: Sized,

Joins the result of two futures, waiting for them both to complete. Read more
source§

fn join3<B, C>( self, b: B, c: C ) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>
where B: IntoFuture<Error = Self::Error>, C: IntoFuture<Error = Self::Error>, Self: Sized,

Same as join, but with more futures.
source§

fn join4<B, C, D>( self, b: B, c: C, d: D ) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>
where B: IntoFuture<Error = Self::Error>, C: IntoFuture<Error = Self::Error>, D: IntoFuture<Error = Self::Error>, Self: Sized,

Same as join, but with more futures.
source§

fn join5<B, C, D, E>( self, b: B, c: C, d: D, e: E ) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>
where B: IntoFuture<Error = Self::Error>, C: IntoFuture<Error = Self::Error>, D: IntoFuture<Error = Self::Error>, E: IntoFuture<Error = Self::Error>, Self: Sized,

Same as join, but with more futures.
source§

fn into_stream(self) -> IntoStream<Self>
where Self: Sized,

Convert this future into a single element stream. Read more
source§

fn fuse(self) -> Fuse<Self>
where Self: Sized,

Fuse a future such that poll will never again be called once it has completed. Read more
source§

fn inspect<F>(self, f: F) -> Inspect<Self, F>
where F: FnOnce(&Self::Item), Self: Sized,

Do something with the item of a future, passing it on. Read more
source§

fn catch_unwind(self) -> CatchUnwind<Self>
where Self: Sized + UnwindSafe,

Catches unwinding panics while polling the future. Read more
source§

fn shared(self) -> Shared<Self>
where Self: Sized,

Create a cloneable handle to this future where all handles will resolve to the same result. Read more
source§

impl Hash for Event

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Event

source§

fn eq(&self, other: &Event) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Event

source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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<F> IntoFuture for F
where F: Future,

§

type Future = F

The future that this type can be converted into.
§

type Item = <F as Future>::Item

The item that the future may resolve with.
§

type Error = <F as Future>::Error

The error that the future may resolve with.
source§

fn into_future(self) -> F

Consumes this object and produces a future.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

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> ToOwned for T
where 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.