aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/CLObjectResource.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp/opencl/CLObjectResource.java')
-rw-r--r--src/com/jogamp/opencl/CLObjectResource.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/CLObjectResource.java b/src/com/jogamp/opencl/CLObjectResource.java
new file mode 100644
index 00000000..fcea22c1
--- /dev/null
+++ b/src/com/jogamp/opencl/CLObjectResource.java
@@ -0,0 +1,51 @@
+/*
+ * Created on Saturday, June 18 2011 02:36
+ */
+package com.jogamp.opencl;
+
+import com.jogamp.common.AutoCloseable;
+
+/**
+ * Releasable resource with an CL object ID.
+ * @author Michael Bien
+ */
+abstract class CLObjectResource extends CLObject implements CLResource, AutoCloseable {
+
+ private boolean released;
+
+ public CLObjectResource(long ID) {
+ super(ID);
+ }
+
+ public CLObjectResource(CLContext context, long ID) {
+ super(context, ID);
+ }
+
+ public void release() {
+ if(released) {
+ throw new RuntimeException(getClass().getSimpleName()+" was already released.");
+ }else{
+ released = true;
+ }
+ }
+
+ /**
+ * Implementation detail.
+ * TODO remove as soon we have extension methods.
+ * @deprecated This method is not intended to be called from client code.
+ * @see java.lang.AutoCloseable
+ */
+ @Deprecated
+ @Override
+ public final void close() {
+ if(this instanceof CLResource) {
+ ((CLResource)this).release();
+ }
+ }
+
+ public boolean isReleased() {
+ return released;
+ }
+
+
+}