diff options
Diffstat (limited to 'src/com/jogamp/opencl/CLEvent.java')
-rw-r--r-- | src/com/jogamp/opencl/CLEvent.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java index b7df1465..8423e7c6 100644 --- a/src/com/jogamp/opencl/CLEvent.java +++ b/src/com/jogamp/opencl/CLEvent.java @@ -1,7 +1,10 @@ package com.jogamp.opencl; +import com.jogamp.opencl.impl.CLEventCallback; +import java.util.List; import com.jogamp.common.nio.PointerBuffer; import java.nio.Buffer; +import java.util.ArrayList; import static com.jogamp.opencl.CL.*; import static com.jogamp.opencl.CLException.*; @@ -25,6 +28,22 @@ public class CLEvent extends CLObject implements CLResource { this.eventProfilingInfo = new CLEventProfilingInfoAccessor(); } + /** + * Registers a callback which will be called when the event terminates (COMPLETE or ERROR). + */ + public void registerCallback(final CLEventListener callback) { + this.registerCallback(callback, ExecutionStatus.COMPLETE); + } + + // apparently only ExecutionStatus.COMPLETE is allowed -> private + private void registerCallback(final CLEventListener callback, ExecutionStatus trigger) { + cl.clSetEventCallback(ID, trigger.STATUS, new CLEventCallback() { + public void eventStateChanged(long event, int status) { + callback.eventStateChanged(CLEvent.this, status); + } + }); + } + public void release() { int ret = cl.clReleaseEvent(ID); checkForError(ret, "can not release event"); |