From 4b96c9539e7b31bbfd5b349d16b51dd5eb556707 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Wed, 16 Jun 2010 20:23:33 +0200 Subject: implemented OpenCL 1.1 user events + JUnit test. --- src/com/jogamp/opencl/CLUserEvent.java | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/com/jogamp/opencl/CLUserEvent.java (limited to 'src/com/jogamp/opencl/CLUserEvent.java') 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; + } + +} -- cgit v1.2.3