summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/util
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-06-19 22:31:05 +0200
committerMichael Bien <[email protected]>2011-06-19 22:31:05 +0200
commit826dacffbae941a35a7cc74515751ddb1d5711a2 (patch)
tree5cf5d5f67ceda1cbf136a6f30295f4ffa8c6c640 /src/com/jogamp/opencl/util
parent00096ac5b2c824fc7e8d7203229c8f246caf833c (diff)
- added isReleased() to CLResource, made CLObject public.
- a CLResource will throw an Exception if released twice.
Diffstat (limited to 'src/com/jogamp/opencl/util')
-rw-r--r--src/com/jogamp/opencl/util/CLMultiContext.java10
-rw-r--r--src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java11
-rw-r--r--src/com/jogamp/opencl/util/concurrent/CLQueueContext.java6
3 files changed, 27 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/util/CLMultiContext.java b/src/com/jogamp/opencl/util/CLMultiContext.java
index eb42092e..156a9fa6 100644
--- a/src/com/jogamp/opencl/util/CLMultiContext.java
+++ b/src/com/jogamp/opencl/util/CLMultiContext.java
@@ -25,6 +25,7 @@ import static com.jogamp.opencl.CLDevice.Type.*;
public class CLMultiContext implements CLResource {
private final List<CLContext> contexts;
+ private boolean released;
private CLMultiContext() {
contexts = new ArrayList<CLContext>();
@@ -132,7 +133,12 @@ public class CLMultiContext implements CLResource {
* Releases all contexts.
* @see CLContext#release()
*/
+ @Override
public void release() {
+ if(released) {
+ throw new RuntimeException(getClass().getSimpleName()+" already released");
+ }
+ released = true;
for (CLContext context : contexts) {
context.release();
}
@@ -154,6 +160,10 @@ public class CLMultiContext implements CLResource {
return devices;
}
+ public boolean isReleased() {
+ return released;
+ }
+
@Override
public String toString() {
return getClass().getSimpleName()+" [" + contexts.size()+" contexts, "
diff --git a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java
index 9ea960ae..e8bd0124 100644
--- a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java
+++ b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java
@@ -29,6 +29,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource
private List<CLQueueContext> contexts;
private ExecutorService excecutor;
private FinishAction finishAction = FinishAction.DO_NOTHING;
+ private boolean released;
private CLCommandQueuePool(CLQueueContextFactory factory, Collection<CLCommandQueue> queues) {
this.contexts = initContexts(queues, factory);
@@ -157,7 +158,12 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource
/**
* Releases all queues.
*/
+ @Override
public void release() {
+ if(released) {
+ throw new RuntimeException(getClass().getSimpleName()+" already released");
+ }
+ released = true;
excecutor.shutdown();
for (CLQueueContext context : contexts) {
context.queue.finish().release();
@@ -187,6 +193,11 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource
return finishAction;
}
+ @Override
+ public boolean isReleased() {
+ return released;
+ }
+
/**
* Sets the action which is run after every completed task.
* This is mainly intended for debugging, default value is {@link FinishAction#DO_NOTHING}.
diff --git a/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java b/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java
index 3f89ad0e..9f92b9a3 100644
--- a/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java
+++ b/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java
@@ -63,10 +63,16 @@ public abstract class CLQueueContext implements CLResource {
return program;
}
+ @Override
public void release() {
program.release();
}
+ @Override
+ public boolean isReleased() {
+ return program.isReleased();
+ }
+
}
}