summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/jogamp/opencl/AutoCloseable.java6
-rw-r--r--src/com/jogamp/opencl/CLCommandQueue.java4
-rw-r--r--src/com/jogamp/opencl/CLContext.java4
-rw-r--r--src/com/jogamp/opencl/CLDevice.java10
-rw-r--r--src/com/jogamp/opencl/CLEvent.java4
-rw-r--r--src/com/jogamp/opencl/CLEventList.java4
-rw-r--r--src/com/jogamp/opencl/CLKernel.java4
-rw-r--r--src/com/jogamp/opencl/CLMemory.java7
-rw-r--r--src/com/jogamp/opencl/CLObject.java15
-rw-r--r--src/com/jogamp/opencl/CLProgram.java4
-rw-r--r--src/com/jogamp/opencl/CLResource.java8
-rw-r--r--src/com/jogamp/opencl/CLSampler.java4
-rw-r--r--src/com/jogamp/opencl/Disposable.java21
13 files changed, 30 insertions, 65 deletions
diff --git a/src/com/jogamp/opencl/AutoCloseable.java b/src/com/jogamp/opencl/AutoCloseable.java
new file mode 100644
index 00000000..6c84ae48
--- /dev/null
+++ b/src/com/jogamp/opencl/AutoCloseable.java
@@ -0,0 +1,6 @@
+package com.jogamp.opencl;
+
+// early import of JDK7's ARM interface for JDK6 backwards compatibility.
+public interface AutoCloseable {
+ void close() throws Exception;
+}
diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java
index ad561747..d7fc7748 100644
--- a/src/com/jogamp/opencl/CLCommandQueue.java
+++ b/src/com/jogamp/opencl/CLCommandQueue.java
@@ -1662,10 +1662,6 @@ public class CLCommandQueue extends CLObject implements CLResource {
}
}
- public void close() {
- release();
- }
-
private static PointerBuffer copy2NIO(PointerBuffer buffer, long a) {
return (PointerBuffer) buffer.put(0, a);
}
diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java
index 12d4f991..7db6e4e5 100644
--- a/src/com/jogamp/opencl/CLContext.java
+++ b/src/com/jogamp/opencl/CLContext.java
@@ -468,10 +468,6 @@ public class CLContext extends CLObject implements CLResource {
}
- public void close() {
- release();
- }
-
protected void overrideContext(CLDevice device) {
device.setContext(this);
}
diff --git a/src/com/jogamp/opencl/CLDevice.java b/src/com/jogamp/opencl/CLDevice.java
index 99ef3fe9..22fc7fcf 100644
--- a/src/com/jogamp/opencl/CLDevice.java
+++ b/src/com/jogamp/opencl/CLDevice.java
@@ -27,7 +27,7 @@ import static com.jogamp.opencl.CL.*;
public final class CLDevice extends CLObject {
private Set<String> extensions;
-
+
private final CLDeviceInfoAccessor deviceInfo;
CLDevice(CL cl, long id) {
@@ -57,13 +57,13 @@ public final class CLDevice extends CLObject {
}
return createCommandQueue(flags);
}
-
+
public CLCommandQueue createCommandQueue(long properties) {
if(context == null)
throw new IllegalStateException("this device is not associated with a context");
return context.createCommandQueue(this, properties);
}
-
+
/*keep this package private*/
void setContext(CLContext context) {
this.context = context;
@@ -535,7 +535,7 @@ public final class CLDevice extends CLObject {
}
}
buffer.rewind();
-
+
return array;
}
@@ -759,7 +759,7 @@ public final class CLDevice extends CLObject {
* Read-write cache.
*/
READ_WRITE(CL_READ_WRITE_CACHE);
-
+
/**
* Value of wrapped OpenCL value.
diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java
index 5b71cc29..b7df1465 100644
--- a/src/com/jogamp/opencl/CLEvent.java
+++ b/src/com/jogamp/opencl/CLEvent.java
@@ -30,10 +30,6 @@ public class CLEvent extends CLObject implements CLResource {
checkForError(ret, "can not release event");
}
- public void close() {
- release();
- }
-
/**
* Returns the execution status of the command which triggers this event.
*/
diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java
index 43f2b36b..a1ee5035 100644
--- a/src/com/jogamp/opencl/CLEventList.java
+++ b/src/com/jogamp/opencl/CLEventList.java
@@ -7,7 +7,7 @@ import java.util.Iterator;
* Fixed size list for storing CLEvents.
* @author Michael Bien
*/
-public final class CLEventList implements CLResource, Iterable<CLEvent> {
+public final class CLEventList implements CLResource, AutoCloseable, Iterable<CLEvent> {
private final CLEvent[] events;
@@ -50,7 +50,7 @@ public final class CLEventList implements CLResource, Iterable<CLEvent> {
IDs.rewind();
}
- public void close() {
+ public final void close() throws Exception {
release();
}
diff --git a/src/com/jogamp/opencl/CLKernel.java b/src/com/jogamp/opencl/CLKernel.java
index 785fbc78..598d43d1 100644
--- a/src/com/jogamp/opencl/CLKernel.java
+++ b/src/com/jogamp/opencl/CLKernel.java
@@ -272,10 +272,6 @@ public class CLKernel extends CLObject implements CLResource, Cloneable {
}
}
- public void close() {
- release();
- }
-
@Override
public String toString() {
return "CLKernel [id: " + ID
diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java
index aac76790..e973fbab 100644
--- a/src/com/jogamp/opencl/CLMemory.java
+++ b/src/com/jogamp/opencl/CLMemory.java
@@ -152,14 +152,11 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
}
}
- public void close() {
- release();
- }
-
- // kept only for debugging purposes
+ // TODO kept only temporary for debugging purposes
/**
* Returns the OpenGL buffer type of this shared buffer.
*/
+ @Deprecated
/*public*/ final GLObjectType _getGLObjectType() {
int[] array = new int[1];
int ret = ((CLGLI)cl).clGetGLObjectInfo(ID, array, 0, null, 0);
diff --git a/src/com/jogamp/opencl/CLObject.java b/src/com/jogamp/opencl/CLObject.java
index ec17a518..3bd7b14b 100644
--- a/src/com/jogamp/opencl/CLObject.java
+++ b/src/com/jogamp/opencl/CLObject.java
@@ -4,7 +4,7 @@ package com.jogamp.opencl;
* Common superclass for all OpenCL objects.
* @author Michael Bien
*/
-abstract class CLObject {
+abstract class CLObject implements AutoCloseable {
/**
* The OpenCL object handle.
@@ -28,6 +28,19 @@ abstract class CLObject {
}
/**
+ * 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
+ public final void close() {
+ if(this instanceof CLResource) {
+ ((CLResource)this).release();
+ }
+ }
+
+ /**
* Returns the context for this OpenCL object.
*/
public CLContext getContext() {
diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java
index 7991b9d6..700446e5 100644
--- a/src/com/jogamp/opencl/CLProgram.java
+++ b/src/com/jogamp/opencl/CLProgram.java
@@ -430,10 +430,6 @@ public class CLProgram extends CLObject implements CLResource {
}
}
- public void close() {
- release();
- }
-
private void releaseKernels() {
if(!kernels.isEmpty()) {
// copy to array to prevent concurrent modification exception
diff --git a/src/com/jogamp/opencl/CLResource.java b/src/com/jogamp/opencl/CLResource.java
index 63b4749e..1ec9e76a 100644
--- a/src/com/jogamp/opencl/CLResource.java
+++ b/src/com/jogamp/opencl/CLResource.java
@@ -4,17 +4,11 @@ package com.jogamp.opencl;
* Releasable OpenCL resource.
* @author Michael Bien
*/
-public interface CLResource extends Disposable<CLException> {
+public interface CLResource {
/**
* Releases the OpenCL resource.
*/
public void release();
- /**
- * Calls {@link #release()};
- * @see #release()
- */
- @Override public void close();
-
}
diff --git a/src/com/jogamp/opencl/CLSampler.java b/src/com/jogamp/opencl/CLSampler.java
index cd5001bf..3ef7520b 100644
--- a/src/com/jogamp/opencl/CLSampler.java
+++ b/src/com/jogamp/opencl/CLSampler.java
@@ -53,10 +53,6 @@ public class CLSampler extends CLObject implements CLResource {
}
}
- public void close() {
- release();
- }
-
private class CLSamplerInfoAccessor extends CLInfoAccessor {
@Override
diff --git a/src/com/jogamp/opencl/Disposable.java b/src/com/jogamp/opencl/Disposable.java
deleted file mode 100644
index 2cd1784b..00000000
--- a/src/com/jogamp/opencl/Disposable.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.jogamp.opencl;
-
-/*
- * JDK7 ARM proposal, cypied to be forward compatible with java 7 automatic resource managment blocks.
- * @author Michael Bien
- */
-
-//package java.lang;
-
-/**
- * A resource that must be closed when it is no longer needed.
- *
- * @param X the type of exception thrown by the close method (or
- * {@link RuntimeException} if the close method is not permitted
- * to throw any checked exceptions).
- */
-/*public*/ interface Disposable<X extends Throwable> {
-
- void close() throws X;
-
-}