java.lang.Object
au.notzed.zcl.CLEventList
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class CLEventList
extends java.lang.Object
implements java.lang.AutoCloseable
Manages a list of cl_events.
This hides some ugly details with the way events work in OpenCL and within this API binding and provides a much cleaner, efficient, and simple interface.
See CLCommandQueue
for more information on usage.
Internal Details
Internally the CLEventList is maintained as a MemorySegment which holds the cl_event pointers. CLEvent objects are only created to access this pointer from Java or to transfer the event pointers to new event lists.
The list is read or written to directly within the CLCommandQueue methods making normal operation very cheap.
Currently event lists are not tracked for garbage collection and must be released() explicitly.
-
Constructor Summary
Constructors Constructor Description CLEventList(int capacity)
Creates a new event list. -
Method Summary
Modifier and Type Method Description void
add(CLEvent event)
Add the event to the event list.void
close()
CLEvent
get(int i)
Creates an interface to the given event.void
release()
Release all resources.void
reset()
Clears the event list.int
size()
Get the number of active events.void
waitForEvents()
Calls clWaitForEvents with all active events in this list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CLEventList
public CLEventList(int capacity)Creates a new event list. The event list MUST be released when done with.- Parameters:
capacity
- Sets the event list capacity.
-
-
Method Details
-
reset
public void reset()Clears the event list.All added events are released and the index counter is reset to 0.
-
release
public void release()Release all resources. Currently this must be called on the same thread that created the event list. -
close
public void close()- Specified by:
close
in interfacejava.lang.AutoCloseable
-
get
Creates an interface to the given event.- Parameters:
i
- index of event.- Returns:
- An event interface.
-
add
Add the event to the event list.- Parameters:
event
-
-
size
public int size()Get the number of active events.- Returns:
-
waitForEvents
Calls clWaitForEvents with all active events in this list.- Throws:
CLException
-