Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Class template wait_guard

boost::compute::wait_guard — A guard object for synchronizing an operation on the device.


// In header: <boost/compute/async/wait_guard.hpp>

template<typename Waitable> 
class wait_guard : private boost::noncopyable {
  // construct/copy/destruct
  wait_guard(const Waitable &);


The wait_guard class stores a waitable object representing an operation on a compute device (e.g. event, future<T>) and calls its wait() method when the guard object goes out of scope.

This is useful for ensuring that an OpenCL operation completes before leaving the current scope and cleaning up any resources.

For example:

// enqueue a compute kernel for execution
event e = queue.enqueue_nd_range_kernel(...);

// call e.wait() upon exiting the current scope
wait_guard<event> guard(e);

wait_list, wait_for_all()

wait_guard public construct/copy/destruct

  1. wait_guard(const Waitable & waitable);
    Creates a new wait_guard object for waitable.
  2. ~wait_guard();

    Destroys the wait_guard object. The default implementation will call wait() on the stored waitable object.