From 0e3893e7e3e270f8231b89eaf89537cf01a43052 Mon Sep 17 00:00:00 2001
From: Michael Bien <mbien@fh-landshut.de>
Date: Thu, 2 Sep 2010 22:50:00 +0200
Subject: CLEvent callbacks for HLB and LLB.

---
 test/com/jogamp/opencl/CLCommandQueueTest.java | 40 +++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

(limited to 'test')

diff --git a/test/com/jogamp/opencl/CLCommandQueueTest.java b/test/com/jogamp/opencl/CLCommandQueueTest.java
index 9c4cc7a8..cafdbc18 100644
--- a/test/com/jogamp/opencl/CLCommandQueueTest.java
+++ b/test/com/jogamp/opencl/CLCommandQueueTest.java
@@ -1,11 +1,13 @@
 package com.jogamp.opencl;
 
+import java.util.concurrent.CountDownLatch;
 import com.jogamp.opencl.util.MultiQueueBarrier;
 import com.jogamp.opencl.CLCommandQueue.Mode;
 import com.jogamp.opencl.CLMemory.Mem;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.EnumSet;
+import java.util.concurrent.TimeUnit;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -172,7 +174,6 @@ public class CLCommandQueueTest {
 
         final int elements = roundUp(groupSize, ONE_MB / SIZEOF_INT * 5); // 5MB per buffer
 
-        // 5MB per buffer
         CLPlatform[] platforms = CLPlatform.listCLPlatforms();
         CLPlatform theChosenOne = platforms[0];
         for (CLPlatform platform : platforms) {
@@ -246,6 +247,43 @@ public class CLCommandQueueTest {
 
     }
 
+    @Test
+    public void eventCallbackTest() throws InterruptedException {
+
+        out.println(" - - - event callback test - - - ");
+
+        CLPlatform platform = CLPlatform.getDefault();
+
+        if(!platform.isAtLeast(CL_1_1)) {
+            out.println("test dissabled, required CLVersion: "+CL_1_1+" available: "+platform.getVersion());
+            return;
+        }
+
+        CLContext context = CLContext.create();
+
+        final CLUserEvent customEvent = CLUserEvent.create(context);
+
+        final CountDownLatch countdown = new CountDownLatch(1);
+        customEvent.registerCallback(new CLEventListener() {
+
+            public void eventStateChanged(CLEvent event, int status) {
+                out.println("event received: "+event);
+                assertEquals(event, customEvent);
+                countdown.countDown();
+            }
+
+        });
+
+        customEvent.setStatus(ExecutionStatus.COMPLETE);
+        countdown.await(2, TimeUnit.SECONDS);
+        assertEquals(countdown.getCount(), 0);
+
+        customEvent.release();
+
+        context.release();
+
+    }
+
     @Test
     public void concurrencyTest() throws IOException, InterruptedException {
 
-- 
cgit v1.2.3