...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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 { public: // public member functions wait_guard(const Waitable &); ~wait_guard(); };
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 member functionswait_guard(const Waitable & waitable);Creates a new wait_guard object for
waitable
. ~wait_guard();
Destroys the wait_guard object. The default implementation will call wait()
on the stored waitable object.