public class CLCommandQueuePool<C extends CLQueueContext> extends Object implements CLResource
ExecutorService
but it uses CLTask
s
instead of Callable
s and provides a per-queue context for resource sharing across all tasks of one queue.Modifier and Type | Class and Description |
---|---|
static class |
CLCommandQueuePool.FinishAction
The action executed after a task completes.
|
Modifier and Type | Method and Description |
---|---|
static <C extends CLQueueContext> |
create(CLQueueContextFactory<C> factory,
CLMultiContext mc,
CLCommandQueue.Mode... modes) |
static <C extends CLQueueContext> |
create(CLQueueContextFactory<C> factory,
Collection<CLCommandQueue> queues) |
static <C extends CLQueueContext> |
create(CLQueueContextFactory<C> factory,
Collection<CLDevice> devices,
CLCommandQueue.Mode... modes) |
void |
finishQueues()
Calls
CLCommandQueue.finish() on all queues. |
void |
flushQueues()
Calls
CLCommandQueue.flush() on all queues. |
CLCommandQueuePool.FinishAction |
getFinishAction() |
List<CLCommandQueue> |
getQueues()
Returns the command queues used in this pool.
|
int |
getSize()
Returns the size of this pool (number of command queues).
|
<R> List<Future<R>> |
invokeAll(Collection<? extends CLTask<? super C,R>> tasks)
Submits all tasks to the pool for immediate execution (blocking) and returns their
Future holding the result. |
<R> List<Future<R>> |
invokeAll(Collection<? extends CLTask<? super C,R>> tasks,
long timeout,
TimeUnit unit)
Submits all tasks to the pool for immediate execution (blocking) and returns their
Future holding the result. |
boolean |
isReleased()
Returns true if
CLResource.release() has been called. |
void |
release()
Releases all queues.
|
void |
setFinishAction(CLCommandQueuePool.FinishAction action)
Sets the action which is run after every completed task.
|
<R> Future<R> |
submit(CLTask<? super C,R> task)
Submits this task to the pool for execution returning its
Future . |
<R> List<Future<R>> |
submitAll(Collection<? extends CLTask<? super C,R>> tasks)
Submits all tasks to the pool for execution and returns their
Future . |
<C extends CLQueueContext> |
switchContext(CLQueueContextFactory<C> factory)
Switches the context of all queues - this operation can be expensive.
|
String |
toString() |
public static <C extends CLQueueContext> CLCommandQueuePool<C> create(CLQueueContextFactory<C> factory, CLMultiContext mc, CLCommandQueue.Mode... modes)
public static <C extends CLQueueContext> CLCommandQueuePool<C> create(CLQueueContextFactory<C> factory, Collection<CLDevice> devices, CLCommandQueue.Mode... modes)
public static <C extends CLQueueContext> CLCommandQueuePool create(CLQueueContextFactory<C> factory, Collection<CLCommandQueue> queues)
public <R> Future<R> submit(CLTask<? super C,R> task)
Future
.public <R> List<Future<R>> submitAll(Collection<? extends CLTask<? super C,R>> tasks)
Future
.
Calls submit(com.jogamp.opencl.util.concurrent.CLTask)
for every task.public <R> List<Future<R>> invokeAll(Collection<? extends CLTask<? super C,R>> tasks) throws InterruptedException
Future
holding the result.InterruptedException
ExecutorService.invokeAll(java.util.Collection)
public <R> List<Future<R>> invokeAll(Collection<? extends CLTask<? super C,R>> tasks, long timeout, TimeUnit unit) throws InterruptedException
Future
holding the result.public <C extends CLQueueContext> CLCommandQueuePool switchContext(CLQueueContextFactory<C> factory)
public void flushQueues()
CLCommandQueue.flush()
on all queues.public void finishQueues()
CLCommandQueue.finish()
on all queues.public void release()
release
in interface CLResource
public List<CLCommandQueue> getQueues()
public int getSize()
public CLCommandQueuePool.FinishAction getFinishAction()
public boolean isReleased()
CLResource
CLResource.release()
has been called.isReleased
in interface CLResource
public void setFinishAction(CLCommandQueuePool.FinishAction action)
CLCommandQueuePool.FinishAction.DO_NOTHING
.