Package com.jogamp.opencl.util
Class MultiQueueBarrier
- java.lang.Object
-
- com.jogamp.opencl.util.MultiQueueBarrier
-
public class MultiQueueBarrier extends Object
An utility for synchronizing multiple concurrentCLCommandQueue
s. This Barrier can be reused after it has been broken.- Author:
- Michael Bien
-
-
Constructor Summary
Constructors Constructor Description MultiQueueBarrier(int queueCount)
Creates a new MultiQueueBarrier with the given queueCount.MultiQueueBarrier(CLCommandQueue... allowedQueues)
Creates a new MultiQueueBarrier for the given queues.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiQueueBarrier
await()
Blocks until all Threads which calledwaitFor(com.jogamp.opencl.CLCommandQueue)
continue execution.boolean
await(long timeout, java.util.concurrent.TimeUnit unit)
long
getCount()
Returns the current number of events which must occure before this barrier unblocks the waiting threads.void
resetBarrier()
Resets this barrier and unblocks all waiting threads.MultiQueueBarrier
waitFor(CLCommandQueue queue)
Blocks the current Thread until all commands on theCLCommandQueue
finished excecution.MultiQueueBarrier
waitFor(CLCommandQueue queue, CLEventList events)
Blocks the current Thread until the given events on theCLCommandQueue
occurred.
-
-
-
Constructor Detail
-
MultiQueueBarrier
public MultiQueueBarrier(int queueCount)
Creates a new MultiQueueBarrier with the given queueCount. It is recommented to useMultiQueueBarrier(CLCommandQueue... allowedQueues)
if possible which restricts the set of allowed queues for the barrier.
-
MultiQueueBarrier
public MultiQueueBarrier(CLCommandQueue... allowedQueues)
Creates a new MultiQueueBarrier for the given queues.
-
-
Method Detail
-
waitFor
public MultiQueueBarrier waitFor(CLCommandQueue queue)
Blocks the current Thread until all commands on theCLCommandQueue
finished excecution. This method may be invoked concurrently without synchronization on the MultiQueueBarrier object as long each Thread passes a distinct CLCommandQueue as parameter to this method.
-
waitFor
public MultiQueueBarrier waitFor(CLCommandQueue queue, CLEventList events)
Blocks the current Thread until the given events on theCLCommandQueue
occurred. This method may be invoked concurrently without synchronization on the MultiQueueBarrier object as long each Thread passes a distinct CLCommandQueue as parameter to this method.
-
await
public MultiQueueBarrier await() throws InterruptedException
Blocks until all Threads which calledwaitFor(com.jogamp.opencl.CLCommandQueue)
continue execution. This method blocks only once, all subsequent calls are ignored.- Throws:
InterruptedException
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit unit) throws InterruptedException
- Parameters:
timeout
- the maximum time to waitunit
- the time unit of thetimeout
argument- Throws:
InterruptedException
- See Also:
await()
-
resetBarrier
public void resetBarrier()
Resets this barrier and unblocks all waiting threads.
-
getCount
public long getCount()
Returns the current number of events which must occure before this barrier unblocks the waiting threads. This method is typically used for debugging and testing purposes.
-
-