diff options
author | Michael Bien <[email protected]> | 2010-02-25 19:03:05 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-02-25 19:03:05 +0100 |
commit | 0b7b387ff2d829f611b385a6aebfe91ee746196a (patch) | |
tree | d000f55eada62084b59df27b38ec1194ba151d40 /src/com/mbien/opencl/QueueBarrier.java | |
parent | 2694d25e5ce59c4f4741b60242331d56601f90d1 (diff) |
renamed QueueBarrier to MultiQueueBarrier.
added cancelBarrier and getCount.
Diffstat (limited to 'src/com/mbien/opencl/QueueBarrier.java')
-rw-r--r-- | src/com/mbien/opencl/QueueBarrier.java | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/com/mbien/opencl/QueueBarrier.java b/src/com/mbien/opencl/QueueBarrier.java deleted file mode 100644 index fc166070..00000000 --- a/src/com/mbien/opencl/QueueBarrier.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.mbien.opencl; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * - * @author Michael Bien - */ -public class QueueBarrier { - - private final CountDownLatch latch; - private final Set<CLCommandQueue> queues; - - public QueueBarrier(int queueCount) { - this.latch = new CountDownLatch(queueCount); - this.queues = null; - } - - public QueueBarrier(CLCommandQueue... allowedQueues) { - this.latch = new CountDownLatch(allowedQueues.length); - - HashSet<CLCommandQueue> set = new HashSet<CLCommandQueue>(allowedQueues.length); - for (CLCommandQueue queue : allowedQueues) { - set.add(queue); - } - this.queues = Collections.unmodifiableSet(set); - } - - /** - * Blocks the current Thread until all commands on the CLCommandQueue finished excecution. - * This method may be invoked concurrently without synchronization on the QueueBarrier object - * as long each Thread passes a distinct CLCommandQueue as parameter to this method. - */ - public QueueBarrier waitFor(CLCommandQueue queue) { - checkQueue(queue); - - queue.putBarrier(); - latch.countDown(); - return this; - } - - /** - * Blocks the current Thread until the given events on the CLCommandQueue occurred. - * This method may be invoked concurrently without synchronization on the QueueBarrier object - * as long each Thread passes a distinct CLCommandQueue as parameter to this method. - */ - public QueueBarrier waitFor(CLCommandQueue queue, CLEventList events) { - checkQueue(queue); - - queue.putWaitForEvents(events, true); - latch.countDown(); - return this; - } - - /** - * Blocks until all Threads which called {@link #waitFor} - * continue excecution. - * This method blocks only once, all subsequent calls are ignored. - */ - public QueueBarrier await() throws InterruptedException { - latch.await(); - return this; - } - - /** - * @see #await() - * @param timeout the maximum time to wait - * @param unit the time unit of the {@code timeout} argument - */ - public QueueBarrier await(long timeout, TimeUnit unit) throws InterruptedException { - latch.await(timeout, unit); - return this; - } - - private void checkQueue(CLCommandQueue queue) throws IllegalArgumentException { - if (queues != null && !queues.contains(queue)) { - throw new IllegalArgumentException(queue + " is not in the allowedQueues Set: " + queues); - } - } - -} |