diff options
author | Michael Bien <[email protected]> | 2011-06-13 18:55:41 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-06-13 18:55:41 +0200 |
commit | 062973e4de89c876f3673d523bb8010822f47564 (patch) | |
tree | 6fcde6f4d1c047416c699ead8bc28c3e16d43890 /src/com/jogamp/opencl/CLEventList.java | |
parent | c06bdd44da347a55d69cc764ecbe698e80db99be (diff) |
added blocking waitForEvents() methods to CLEventList.
Diffstat (limited to 'src/com/jogamp/opencl/CLEventList.java')
-rw-r--r-- | src/com/jogamp/opencl/CLEventList.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java index 8c09f60f..53d59d41 100644 --- a/src/com/jogamp/opencl/CLEventList.java +++ b/src/com/jogamp/opencl/CLEventList.java @@ -98,6 +98,41 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL events[size] = new CLEvent(context, IDs.get()); size++; } + + NativeSizeBuffer getEventBuffer(int index) { + return NativeSizeBuffer.wrap(IDs.getBuffer().duplicate()).position(index); + } + + /** + * Waits for all events in this list to occur. + * If this list is empty this method won't do anything. + */ + public void waitForEvents() { + if(size > 0) { + events[0].getPlatform().getEventBinding().clWaitForEvents(size, IDsView); + } + } + + /** + * Waits for all events of the specified region in this list to occur. + * Will throw IndexOutOfBoundsException if indices are out of bounds. + */ + public void waitForEvents(int start, int range) { + if(start+range < size || range <= 0) { + throw new IndexOutOfBoundsException("args: [start: "+start+" range: "+range+"], eventcount: "+size); + } + + NativeSizeBuffer view = getEventBuffer(start); + getEvent(start).getPlatform().getEventBinding().clWaitForEvents(range, view); + } + + /** + * Waits for the event with the given index in this list to occur. + */ + public void waitForEvent(int index) { + NativeSizeBuffer view = getEventBuffer(index); + getEvent(index).getPlatform().getEventBinding().clWaitForEvents(1, view); + } /** * Releases all CLEvents in this list. |