Struct ocl::async::RwVec

source ·
pub struct RwVec<T> { /* private fields */ }
Expand description

A locking Vec which interoperates with OpenCL events and Rust futures to provide exclusive access to data.

Calling ::read or ::write returns a future which will resolve into a RwGuard.

§Platform Compatibility

Some CPU device/platform combinations have synchronization problems when accessing an RwVec from multiple threads. Known platforms with problems are 2nd and 4th gen Intel Core processors (Sandy Bridge and Haswell) with Intel OpenCL CPU drivers. Others may be likewise affected. Run the device_check.rs example to determine if your device/platform is affected. AMD platform drivers are known to work properly on the aforementioned CPUs so use those instead if possible.

Implementations§

source§

impl<T> RwVec<T>

source

pub fn new() -> RwVec<T>

Creates and returns a new RwVec.

source

pub fn read(self) -> FutureGuard<Vec<T>, ReadGuard<Vec<T>>>

Returns a new FutureRwGuard which will resolve into a a RwGuard.

source

pub fn write(self) -> FutureGuard<Vec<T>, WriteGuard<Vec<T>>>

Returns a new FutureRwGuard which will resolve into a a RwGuard.

source

pub unsafe fn as_mut_slice(&mut self) -> &mut [T]

Returns a mutable slice into the contained Vec.

Used by buffer command builders when preparing future read and write commands.

Do not use unless you are 100% certain that there will be no other reads or writes for the entire access duration (only possible if manually manipulating the lock status).

source

pub fn len_stale(&self) -> usize

Returns the length of the internal Vec.

§Concurrency Considerations

The returned length is to be considered immediately stale (out of date) due to the fact that other threads may be modifying it. To obtain an accurate state of the internal Vec, the containing RwVec must first be locked with ::read or ::write.

source

pub fn id(&self) -> usize

Returns a pointer address to the internal array, usable as a unique identifier.

Note that resizing the Vec will likely change the address. Also, the same ‘id’ could be reused by another RwVec created after this one is dropped.

Methods from Deref<Target = OrderLock<Vec<T>>>§

source

pub fn as_ptr(&self) -> *const V

Returns a reference to the inner value.

source

pub fn as_mut_ptr(&self) -> *mut V

Returns a mutable reference to the inner value.

Trait Implementations§

source§

impl<T: Clone> Clone for RwVec<T>

source§

fn clone(&self) -> RwVec<T>

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<T: Debug> Debug for RwVec<T>

source§

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

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

impl<T> Deref for RwVec<T>

§

type Target = OrderLock<Vec<T>>

The resulting type after dereferencing.
source§

fn deref(&self) -> &OrderLock<Vec<T>>

Dereferences the value.
source§

impl<T> DerefMut for RwVec<T>

source§

fn deref_mut(&mut self) -> &mut OrderLock<Vec<T>>

Mutably dereferences the value.
source§

impl<'a, 'd, T> From<&'a RwVec<T>> for WriteSrc<'d, T>
where T: OclPrm,

source§

fn from(rw_vec: &'a RwVec<T>) -> WriteSrc<'d, T>

Converts to this type from the input type.
source§

impl<T> From<QrwLock<Vec<T>>> for RwVec<T>

source§

fn from(q: QrwLock<Vec<T>>) -> RwVec<T>

Converts to this type from the input type.
source§

impl<'d, T> From<RwVec<T>> for WriteSrc<'d, T>
where T: OclPrm,

source§

fn from(rw_vec: RwVec<T>) -> WriteSrc<'d, T>

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for RwVec<T>

source§

fn from(vec: Vec<T>) -> RwVec<T>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for RwVec<T>

§

impl<T> !RefUnwindSafe for RwVec<T>

§

impl<T> Send for RwVec<T>
where T: Send,

§

impl<T> Sync for RwVec<T>
where T: Send,

§

impl<T> Unpin for RwVec<T>

§

impl<T> !UnwindSafe for RwVec<T>

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