# Struct ocl::builders::BufferReadCmd [−] [src]

    #[must_use = "commands do nothing unless enqueued"]
    pub struct BufferReadCmd<'c, 'd, T> where
        T: 'c + 'd + OclPrm,  { /* fields omitted */ }

A buffer command builder used to enqueue reads.

See SDK docs for more details.

## Methods

### `impl<'c, 'd, T> BufferReadCmd<'c, 'd, T> where
T: OclPrm,`
[src]

#### `pub fn queue(self, queue: &'c Queue) -> BufferReadCmd<'c, 'd, T>`
[src]

Specifies a queue to use for this call only.

Overrides the buffer's default queue if one is set. If no default queue is set, this method must be called before enqueuing the command.

#### `pub unsafe fn block(self, block: bool) -> BufferReadCmd<'c, 'd, T>`
[src]

Specifies whether or not to block the current thread until completion.

Ignored if this is not a read or write operation.

Default is `block = true`.

## Safety

When performing non-blocking reads or writes, the caller must ensure that the data being read from or written to is not accessed improperly until the command completes. Use events (`Event::wait_for`) or the command queue (`Queue::finish`) to synchronize.

If possible, prefer instead to use `::map` with `::enq_async` for optimal performance and data integrity.

#### `pub fn offset(self, offset: usize) -> BufferReadCmd<'c, 'd, T>`
[src]

Sets the linear offset for an operation.

## Panics

The 'shape' may not have already been set to rectangular by the `::rect` function.

#### `pub fn dst_offset(self, dst_offset: usize) -> BufferReadCmd<'c, 'd, T>`
[src]

Sets an offset into the destination data.

Equivalent to setting the start position of a slice into the destination data (e.g. `dst_data[dst_offset..]`). Use `::len` to set the end position (resulting in `dst_data[dst_offset..len]`).

Defaults to 0 if not set. Panics if `::rect` has been called.

#### `pub fn len(self, len: usize) -> BufferReadCmd<'c, 'd, T>`
[src]

Sets the total length of data to read.

Equivalent to setting the end position of a slice into the destination data (e.g. `destination[..len]`). Use `::dst_offset` to set the start position (resulting in `dst_data[dst_offset..len]`).

Defaults to the total length of the read destination provided. Panics if `::rect` has been called.

#### `pub fn rect(
self,
src_origin: [usize; 3],
dst_origin: [usize; 3],
region: [usize; 3],
src_row_pitch_bytes: usize,
src_slc_pitch_bytes: usize,
dst_row_pitch_bytes: usize,
dst_slc_pitch_bytes: usize
) -> BufferReadCmd<'c, 'd, T>`
[src]

Specifies that this will be a rectangularly shaped operation (the default being linear).

Row and slice pitches must all be expressed in bytes.

Panics if `:offset`, `dst_offset`, or `::len` have been called.

#### `pub fn ewait<'e, Ewl>(self, ewait: Ewl) -> BufferReadCmd<'c, 'd, T> where
'e: 'c,
Ewl: Into<ClWaitListPtrEnum<'e>>,`
[src]

Specifies an event or list of events to wait on before the command will run.

When events generated using the `::enew` method of other, previously enqueued commands are passed here (either individually or as part of an `EventList`), this command will not execute until those commands have completed.

Using events can compliment the use of queues to order commands by creating temporal dependencies between them (where commands in one queue must wait for the completion of commands in another). Events can also supplant queues altogether when, for example, using out-of-order queues.

# Example

ⓘThis example is not tested

    // Create an event list:
    let mut event_list = EventList::new();
    // Enqueue a kernel on `queue_1`, creating an event representing the kernel
    // command in our list:
    kernel.cmd().queue(&queue_1).enew(&mut event_list).enq()?;
    // Read from a buffer using `queue_2`, ensuring the read does not begin until
    // after the kernel command has completed:
    buffer.read(rwvec.clone()).queue(&queue_2).ewait(&event_list).enq_async()?;

#### `pub fn enew<'e, En>(self, enew: En) -> BufferReadCmd<'c, 'd, T> where
'e: 'c,
En: Into<ClNullEventPtrEnum<'e>>,`
[src]

Specifies the destination to store a new, optionally created event associated with this command.

The destination can be a mutable reference to an empty event (created using `Event::empty`) or a mutable reference to an event list.

After this command is enqueued, the event in the destination can be passed to the `::ewait` method of another command. Doing so will cause the other command to wait until this command has completed before executing.

Using events can compliment the use of queues to order commands by creating temporal dependencies between them (where commands in one queue must wait for the completion of commands in another). Events can also supplant queues altogether when, for example, using out-of-order queues.

# Example

ⓘThis example is not tested

    // Create an event list:
    let mut event = Event::empty();
    // Enqueue a kernel on `queue_1`, creating an event representing the kernel
    // command in our list:
    kernel.cmd().queue(&queue_1).enew(&mut event).enq()?;
    // Read from a buffer using `queue_2`, ensuring the read does not begin until
    // after the kernel command has completed:
    buffer.read(rwvec.clone()).queue(&queue_2).ewait(&event).enq_async()?;

#### `pub fn enq(self) -> OclResult<()>`
[src]

Enqueues this command, blocking the current thread until it is complete.

If an `RwVec` is being used as the data destination, the current thread will be blocked until an exclusive lock can be obtained before running the command (which will also block for its duration).

#### `pub fn enq_async(self) -> OclResult<FutureWriteGuard<Vec<T>>>`
[src]

Enqueues this command and returns a future representing its completion which resolves to a guard providing exclusive data access usable within subsequent futures.

A data destination container appropriate for an asynchronous operation (such as `RwVec`) must have been passed to `::read`.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)