summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/CLUserEvent.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-06-16 20:23:33 +0200
committerMichael Bien <[email protected]>2010-06-16 20:23:33 +0200
commit4b96c9539e7b31bbfd5b349d16b51dd5eb556707 (patch)
treea08563d3fb71af931181823a1f4eee6fc4981ac9 /src/com/jogamp/opencl/CLUserEvent.java
parent35c9254adf4448c5eb86239118c5fb1dd6db88b8 (diff)
implemented OpenCL 1.1 user events + JUnit test.
Diffstat (limited to 'src/com/jogamp/opencl/CLUserEvent.java')
-rw-r--r--src/com/jogamp/opencl/CLUserEvent.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/CLUserEvent.java b/src/com/jogamp/opencl/CLUserEvent.java
new file mode 100644
index 00000000..56fb7a0c
--- /dev/null
+++ b/src/com/jogamp/opencl/CLUserEvent.java
@@ -0,0 +1,59 @@
+/*
+ * Created on Wednesday, June 16 2010 18:05
+ */
+
+package com.jogamp.opencl;
+
+import static com.jogamp.opencl.CLException.*;
+import static com.jogamp.opencl.CL.*;
+
+/**
+ * Custom, user controlled event.
+ * @see CLEvent
+ * @author Michael Bien
+ */
+public class CLUserEvent extends CLEvent {
+
+ CLUserEvent(CLContext context, long ID) {
+ super(context, ID);
+ }
+
+ /**
+ * Creates a new user event.
+ */
+ public static CLUserEvent create(CLContext context) {
+ int[] error = new int[1];
+ long ID = context.cl.clCreateUserEvent(context.ID, error, 0);
+ checkForError(error[0], "can not create user event.");
+ return new CLUserEvent(context, ID);
+ }
+
+ /**
+ * Sets the event execution status.
+ * Calls {@native clSetUserEventStatus}.
+ */
+ public CLUserEvent setStatus(CLEvent.ExecutionStatus status) {
+ int err = cl.clSetUserEventStatus(ID, status.STATUS);
+ if(err != CL_SUCCESS) {
+ newException(err, "can not set status "+status);
+ }
+ return this;
+ }
+
+ /**
+ * Sets this event's status to {@link CLEvent.ExecutionStatus#COMPLETE}.
+ * @see #setStatus(com.jogamp.opencl.CLEvent.ExecutionStatus)
+ */
+ public CLUserEvent setComplete() {
+ return setStatus(ExecutionStatus.COMPLETE);
+ }
+
+ /**
+ * Returns {@link CLEvent.CommandType#USER}.
+ */
+ @Override
+ public CommandType getType() {
+ return CommandType.USER;
+ }
+
+}