From 0e3893e7e3e270f8231b89eaf89537cf01a43052 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Thu, 2 Sep 2010 22:50:00 +0200 Subject: CLEvent callbacks for HLB and LLB. --- src/com/jogamp/opencl/CLEvent.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/com/jogamp/opencl/CLEvent.java') 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"); -- cgit v1.2.3