Struct ocl::async::FutureRwGuard
[−]
[src]
#[must_use = "futures do nothing unless polled"]pub struct FutureRwGuard<T, G> { /* fields omitted */ }
A future that resolves to a read or write guard after ensuring that the data being guarded is appropriately locked during the execution of an OpenCL command.
- Waits until both an exclusive data lock can be obtained and all prerequisite OpenCL commands have completed.
- Triggers an OpenCL command, remaining locked while the command executes.
- Returns a guard which provides exclusive (write) or shared (read) access to the locked data.
Methods
impl<T, G> FutureRwGuard<T, G> where
G: RwGuard<T>,
[src]
G: RwGuard<T>,
fn set_wait_list<L: Into<EventList>>(&mut self, wait_list: L)
Sets an event wait list.
Setting a wait list will cause this FutureRwGuard
to wait until
contained events have their status set to complete before obtaining a
lock on the guarded internal Vec
.
[UNSTABLE]: This method may be renamed or otherwise changed at any time.
fn set_command_completion_event(&mut self, command_completion: Event)
Sets a command completion event.
If a command completion event corresponding to the read or write
command being executed in association with this FutureRwGuard
is
specified before this FutureRwGuard
is polled it will cause this
FutureRwGuard
to suffix itself with an additional future that will
wait until the command completion event completes before resolving
into an RwGuard
.
Not specifying a command completion event will cause this
FutureRwGuard
to resolve into an RwGuard
immediately after the
lock is obtained (indicated by the optionally created lock event).
TODO: Reword this. [UNSTABLE]: This method may be renamed or otherwise changed at any time.
fn create_lock_event<C: ClContextPtr>(
&mut self,
context: C
) -> AsyncResult<&Event>
&mut self,
context: C
) -> AsyncResult<&Event>
Creates an event which will be triggered when a lock is obtained on
the guarded internal Vec
.
The returned event can be added to the wait list of subsequent OpenCL commands with the expectation that when all preceding futures are complete, the event will automatically be 'triggered' by having its status set to complete, causing those commands to execute. This can be used to inject host side code in amongst OpenCL commands without thread blocking or extra delays of any kind.
fn create_release_event<C: ClContextPtr>(
&mut self,
context: C
) -> AsyncResult<&Event>
&mut self,
context: C
) -> AsyncResult<&Event>
Creates an event which will be triggered after this future resolves
and the ensuing RwGuard
is dropped or manually released.
The returned event can be added to the wait list of subsequent OpenCL commands with the expectation that when all preceding futures are complete, the event will automatically be 'triggered' by having its status set to complete, causing those commands to execute. This can be used to inject host side code in amongst OpenCL commands without thread blocking or extra delays of any kind.
[UNSTABLE]: This method may be renamed or otherwise changed at any time.
fn lock_event(&self) -> Option<&Event>
Returns a reference to the event previously created with
::create_lock_event
which will trigger (be completed) when the wait
events are complete and the lock is locked.
fn release_event(&self) -> Option<&Event>
Returns a reference to the event previously created with
::create_release_event
which will trigger (be completed) when a lock
is obtained on the guarded internal Vec
.
[UNSTABLE]: This method may be renamed or otherwise changed at any time.
fn wait(self) -> AsyncResult<G>
Blocks the current thread until the OpenCL command is complete and an appropriate lock can be obtained on the underlying data.
unsafe fn as_mut_ptr(&self) -> Option<*mut T>
Returns a mutable pointer to the data contained within the internal
Vec
, bypassing all locks and protections.
unsafe fn as_mut_slice<'a, 'b>(&'a self) -> Option<&'b mut [T]>
Returns a mutable slice to the data contained within the internal
Vec
, bypassing all locks and protections.
fn len(&self) -> usize
Returns the length of the internal Vec
.
impl<T> FutureRwGuard<T, ReadGuard<T>>
[src]
fn upgrade_after_command(self) -> FutureWriter<T>
Trait Implementations
impl<T: Debug, G: Debug> Debug for FutureRwGuard<T, G>
[src]
impl<T, G> Future for FutureRwGuard<T, G> where
G: RwGuard<T>,
[src]
G: RwGuard<T>,
type Item = G
The type of value that this future will resolved with if it is successful. Read more
type Error = AsyncError
The type of error that this future will resolve with if it fails in a normal fashion. Read more
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
fn wait(self) -> Result<Self::Item, Self::Error>
Block the current thread until this future is resolved. Read more
fn boxed(
self
) -> Box<Future<Error = Self::Error, Item = Self::Item> + 'static + Send> where
Self: Send + 'static,
self
) -> Box<Future<Error = Self::Error, Item = Self::Item> + 'static + Send> where
Self: Send + 'static,
Convenience function for turning this future into a trait object which is also Send
. Read more
fn map<F, U>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Item) -> U,
F: FnOnce(Self::Item) -> U,
Map this future's result to a different type, returning a new future of the resulting type. Read more
fn map_err<F, E>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
F: FnOnce(Self::Error) -> E,
Map this future's error to a different error, returning a new future. Read more
fn from_err<E>(self) -> FromErr<Self, E> where
E: From<Self::Error>,
E: From<Self::Error>,
Map this future's error to any error implementing From
for this future's Error
, returning a new future. Read more
fn then<F, B>(self, f: F) -> Then<Self, B, F> where
B: IntoFuture,
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
B: IntoFuture,
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
Chain on a computation for when a future finished, passing the result of the future to the provided closure f
. Read more
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where
B: IntoFuture<Error = Self::Error>,
F: FnOnce(Self::Item) -> B,
B: IntoFuture<Error = Self::Error>,
F: FnOnce(Self::Item) -> B,
Execute another future after this one has resolved successfully. Read more
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F> where
B: IntoFuture<Item = Self::Item>,
F: FnOnce(Self::Error) -> B,
B: IntoFuture<Item = Self::Item>,
F: FnOnce(Self::Error) -> B,
Execute another future if this one resolves with an error. Read more
fn select<B>(self, other: B) -> Select<Self, B::Future> where
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
Waits for either one of two futures to complete. Read more
fn select2<B>(self, other: B) -> Select2<Self, B::Future> where
B: IntoFuture,
B: IntoFuture,
Waits for either one of two differently-typed futures to complete. Read more
fn join<B>(self, other: B) -> Join<Self, B::Future> where
B: IntoFuture<Error = Self::Error>,
B: IntoFuture<Error = Self::Error>,
Joins the result of two futures, waiting for them both to complete. Read more
fn join3<B, C>(self, b: B, c: C) -> Join3<Self, B::Future, C::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
Same as join
, but with more futures.
fn join4<B, C, D>(
self,
b: B,
c: C,
d: D
) -> Join4<Self, B::Future, C::Future, D::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
self,
b: B,
c: C,
d: D
) -> Join4<Self, B::Future, C::Future, D::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Same as join
, but with more futures.
fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, B::Future, C::Future, D::Future, E::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, B::Future, C::Future, D::Future, E::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Same as join
, but with more futures.
fn into_stream(self) -> IntoStream<Self>
Convert this future into a single element stream. Read more
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoFuture,
Self::Item::Error: From<Self::Error>,
Self::Item: IntoFuture,
Self::Item::Error: From<Self::Error>,
Flatten the execution of this future when the successful result of this future is itself another future. Read more
fn flatten_stream(self) -> FlattenStream<Self> where
Self::Item: Stream,
Self::Item::Error == Self::Error,
Self::Item: Stream,
Self::Item::Error == Self::Error,
Flatten the execution of this future when the successful result of this future is a stream. Read more
fn fuse(self) -> Fuse<Self>
Fuse a future such that poll
will never again be called once it has completed. Read more
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
Self: UnwindSafe,
Catches unwinding panics while polling the future. Read more
Create a cloneable handle to this future where all handles will resolve to the same result. Read more
impl<T, G> Drop for FutureRwGuard<T, G>
[src]
fn drop(&mut self)
Drops this FutureRwGuard.
Blocks the current thread until the command associated with this
FutureRwGuard
(represented by the command completion event)
completes. This ensures that the underlying Vec
is not dropped
before the command completes (which would cause obvious problems).