pub struct OpenClMem { /* private fields */ }Expand description
cl_mem handle paired with its producing cl_command_queue.
row_pitch is meaningful only for cl_mem BUFFER objects holding
image data with non-tight rows; see the documentation on the
OpenCl variant for the full contract.
Implementations§
Source§impl OpenClMem
impl OpenClMem
Sourcepub unsafe fn try_from_raw(
mem: *mut c_void,
queue: *mut c_void,
row_pitch: u32,
keep_alive: Option<KeepAlive>,
) -> Result<Self, InvalidHandleError>
pub unsafe fn try_from_raw( mem: *mut c_void, queue: *mut c_void, row_pitch: u32, keep_alive: Option<KeepAlive>, ) -> Result<Self, InvalidHandleError>
Wrap a raw cl_mem together with the cl_command_queue that
produced it. Borrowing: the handle is stored non-owningly, this
type has no Drop, and every obligation below extends to each
Clone.
§Safety
memmust be a livecl_memwhose OpenCL reference count is at least one.queuemust be a livecl_command_queueon a context that ownsmem. Consumers enqueue againstqueuenamingmem; an unrelated context makes that an invalid-object call at best and undefined at worst. Null for either is rejected asInvalidHandleError::NullPointerand is not a caller obligation.- Refcount: neither
clRetainMemObjectnorclRetainCommandQueueis called here, and there is noDropthat releases. The caller’s references on both objects must outlive this value and everyCloneof it — pass akeep_aliveanchor that holds them, or carry the obligation directly when it isNone. Releasing either while a clone survives is a use-after-free. row_pitchis meaningful only whenmemis a BUFFER object holding image rows that are not tightly packed; it must then be the real row stride in bytes, since consumers index rows by it. Pass0for image objects and tightly-packed buffers.- Cross-thread:
OpenClMemisSend + Sync. OpenCL objects are thread-safe under the 1.2+ spec, but a singlecl_command_queueis only safe to enqueue on concurrently because the runtime serialises it — the caller must still not assume ordering between its own enqueues and the consumer’s.
pub fn mem(&self) -> *mut c_void
pub fn queue(&self) -> *mut c_void
pub fn row_pitch(&self) -> u32
pub fn keep_alive(&self) -> Option<&KeepAlive>
Trait Implementations§
impl Send for OpenClMem
impl Sync for OpenClMem
Auto Trait Implementations§
impl !RefUnwindSafe for OpenClMem
impl !UnwindSafe for OpenClMem
impl Freeze for OpenClMem
impl Unpin for OpenClMem
impl UnsafeUnpin for OpenClMem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more