diff options
author | Michael Bien <[email protected]> | 2010-09-02 23:45:05 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-09-02 23:45:05 +0200 |
commit | bc4e1521cc2ccc91a033998847dc35e1a8c8687b (patch) | |
tree | ebd2a6e94b69519afc5aed07ebf49b03b80fbaea /test/com/jogamp/opencl/CLBufferTest.java | |
parent | 048f09aafe49e4eaddfe25ec4b302268510bc27b (diff) |
CLMemObjectDestructorCallback for HLB and LLB.
Diffstat (limited to 'test/com/jogamp/opencl/CLBufferTest.java')
-rw-r--r-- | test/com/jogamp/opencl/CLBufferTest.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/test/com/jogamp/opencl/CLBufferTest.java b/test/com/jogamp/opencl/CLBufferTest.java index f2d2d609..92f94831 100644 --- a/test/com/jogamp/opencl/CLBufferTest.java +++ b/test/com/jogamp/opencl/CLBufferTest.java @@ -5,6 +5,8 @@ import com.jogamp.opencl.CLMemory.Map; import com.jogamp.common.nio.Buffers; import java.nio.ByteBuffer; import java.nio.FloatBuffer; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.junit.Test; import static org.junit.Assert.*; @@ -150,6 +152,8 @@ public class CLBufferTest { @Test public void subBufferTest() { + out.println(" - - - subBufferTest - - - "); + CLPlatform[] platforms = CLPlatform.listCLPlatforms(); CLPlatform theChosenOne = null; for (CLPlatform platform : platforms) { @@ -215,5 +219,43 @@ public class CLBufferTest { } } - + + @Test + public void destructorCallbackTest() throws InterruptedException { + + out.println(" - - - destructorCallbackTest - - - "); + + CLPlatform platform = CLPlatform.getDefault(); + if(!platform.isAtLeast(CLVersion.CL_1_1)) { + out.println("aborting destructorCallbackTest"); + return; + } + + CLContext context = CLContext.create(platform); + + try{ + + final CLBuffer<?> buffer = context.createBuffer(32); + final CountDownLatch countdown = new CountDownLatch(1); + + buffer.registerDestructorCallback(new CLMemObjectListener() { + public void memoryDeallocated(CLMemory<?> mem) { + out.println("buffer released"); + assertEquals(mem, buffer); + countdown.countDown(); + } + }); + buffer.release(); + + countdown.await(2, TimeUnit.SECONDS); + assertEquals(countdown.getCount(), 0); + + }finally{ + context.release(); + } + + + } + + } |