diff options
Diffstat (limited to 'src/com/jogamp/opencl/CLMemory.java')
-rw-r--r-- | src/com/jogamp/opencl/CLMemory.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java index d66db3c8..416b8019 100644 --- a/src/com/jogamp/opencl/CLMemory.java +++ b/src/com/jogamp/opencl/CLMemory.java @@ -3,6 +3,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.gl.CLGLI; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; +import com.jogamp.opencl.impl.CLMemObjectDestructorCallback; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.DoubleBuffer; @@ -73,6 +74,18 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL } /** + * Registers a callback which will be called by the OpenCL implementation + * when the memory object is released. + */ + public void registerDestructorCallback(final CLMemObjectListener listener) { + cl.clSetMemObjectDestructorCallback(ID, new CLMemObjectDestructorCallback() { + public void memoryDeallocated(long memObjID) { + listener.memoryDeallocated(CLMemory.this); + } + }); + } + + /** * Returns a new instance of CLMemory pointing to the same CLResource but using a different Buffer. */ public abstract <T extends Buffer> CLMemory<T> cloneWith(T directBuffer); |