#[repr(C)]pub struct Event(/* private fields */);
Expand description
An event representing a command or user created event.
Implementations§
source§impl Event
impl Event
sourcepub fn empty() -> Event
pub fn empty() -> Event
Creates a new, empty (null) event which must be filled by a command, associating the event with it.
sourcepub fn user<C: ClContextPtr>(context: C) -> OclResult<Event>
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.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this event is ‘empty’ and has not yet been associated with a command.
sourcepub fn set_unpark_callback(&self) -> OclResult<()>
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.
sourcepub unsafe fn register_event_relay(&self, user_event: Event) -> OclResult<()>
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).
sourcepub fn info(&self, info_kind: EventInfo) -> OclResult<EventInfoResult>
pub fn info(&self, info_kind: EventInfo) -> OclResult<EventInfoResult>
Returns info about the event.
sourcepub fn profiling_info(
&self,
info_kind: ProfilingInfo
) -> OclResult<ProfilingInfoResult>
pub fn profiling_info( &self, info_kind: ProfilingInfo ) -> OclResult<ProfilingInfoResult>
Returns info about the event.
sourcepub fn queue_core(&self) -> OclResult<CommandQueueCore>
pub fn queue_core(&self) -> OclResult<CommandQueueCore>
Returns this event’s associated command queue.
sourcepub fn as_core(&self) -> &EventCore
pub fn as_core(&self) -> &EventCore
Returns a reference to the core pointer wrapper, usable by functions in
the core
module.
sourcepub fn into_raw(self) -> cl_event
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
.
sourcepub unsafe fn from_raw(ptr: cl_event) -> Event
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>§
sourcepub fn set_complete(&self) -> Result<(), Error>
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()
).
sourcepub fn is_complete(&self) -> Result<bool, Error>
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.
sourcepub fn wait_for(&self) -> Result<(), Error>
pub fn wait_for(&self) -> Result<(), Error>
Causes the command queue to wait until this event is complete before returning.
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns whether or not this event is associated with a command or is a user event.
sourcepub fn is_valid(&self) -> bool
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.
sourcepub 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>
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
.
sourcepub fn context(&self) -> Result<Context, Error>
pub fn context(&self) -> Result<Context, Error>
Returns the Context
associated with this event.
sourcepub unsafe fn as_ptr_ref(&self) -> &*mut c_void
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.
sourcepub unsafe fn as_ptr_mut(&mut self) -> &mut *mut c_void
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<'e> ClEventPtrRef<'e> for Event
impl<'e> ClEventPtrRef<'e> for Event
unsafe fn as_ptr_ref(&'e self) -> &'e cl_event
source§impl<'a> ClNullEventPtr for &'a mut Event
impl<'a> ClNullEventPtr for &'a mut Event
source§impl<'a> ClWaitListPtr for &'a Event
impl<'a> ClWaitListPtr for &'a Event
source§impl ClWaitListPtr for Event
impl ClWaitListPtr for Event
source§impl<'a> From<&'a Event> for ClWaitListPtrEnum<'a>
impl<'a> From<&'a Event> for ClWaitListPtrEnum<'a>
source§fn from(e: &'a Event) -> ClWaitListPtrEnum<'a>
fn from(e: &'a Event) -> ClWaitListPtrEnum<'a>
source§impl<'a> From<&'a mut Event> for ClNullEventPtrEnum<'a>
impl<'a> From<&'a mut Event> for ClNullEventPtrEnum<'a>
source§fn from(e: &'a mut Event) -> ClNullEventPtrEnum<'a>
fn from(e: &'a mut Event) -> ClNullEventPtrEnum<'a>
source§impl<'a> From<&'a mut Event> for ClWaitListPtrEnum<'a>
impl<'a> From<&'a mut Event> for ClWaitListPtrEnum<'a>
source§fn from(e: &'a mut Event) -> ClWaitListPtrEnum<'a>
fn from(e: &'a mut Event) -> ClWaitListPtrEnum<'a>
source§impl<'a> From<Event> for ClWaitListPtrEnum<'a>
impl<'a> From<Event> for ClWaitListPtrEnum<'a>
source§fn from(e: Event) -> ClWaitListPtrEnum<'a>
fn from(e: Event) -> ClWaitListPtrEnum<'a>
source§impl<'a> From<Event> for EventArray
impl<'a> From<Event> for EventArray
source§fn from(event: Event) -> EventArray
fn from(event: Event) -> EventArray
source§impl Future for Event
impl Future for Event
§type Error = Error
type Error = Error
source§fn poll(&mut self) -> Poll<Self::Item, Self::Error>
fn poll(&mut self) -> Poll<Self::Item, Self::Error>
source§fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
source§fn map<F, U>(self, f: F) -> Map<Self, F>
fn map<F, U>(self, f: F) -> Map<Self, F>
source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
source§fn from_err<E>(self) -> FromErr<Self, E>
fn from_err<E>(self) -> FromErr<Self, E>
From
for
this future’s Error
, returning a new future. Read moresource§fn then<F, B>(self, f: F) -> Then<Self, B, F>
fn then<F, B>(self, f: F) -> Then<Self, B, F>
f
. Read moresource§fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
source§fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>
source§fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>
fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>
source§fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
source§fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>
fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>
source§fn join3<B, C>(
self,
b: B,
c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>
fn join3<B, C>( self, b: B, c: C ) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>
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,
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,
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,
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,
join
, but with more futures.source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. Read more