blob: b7ac9b4f139b49f97232e2ec86d5771549fefb68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// OpenCL event object
// (c) EB Sep 2009
#ifndef CLEvent_h
#define CLEvent_h
#include <CL/cl.h>
#include "CLError.h"
namespace cl {
class Event
{
public:
// Instances of this class are created by calls in a CommandQueue.
// Copy constructor
Event(const Event & a) : mX(a.mX)
{ if (mX != 0) clRetainEvent(mX); }
// = operator
Event & operator = (const Event & a)
{
if (a.mX != mX)
{
if (mX != 0) clReleaseEvent(mX);
mX = a.mX;
if (mX != 0) clRetainEvent(mX);
}
return *this;
}
// Destructor
virtual ~Event()
{ if (mX != 0) clReleaseEvent(mX); }
// Check if the event is valid
bool isValid() const { return (mX != 0); }
// Wait for this event to complete.
// Return TRUE if OK, and FALSE otherwise.
// If the event is invalid, return TRUE.
bool wait()
{
if (mX == 0) return true; // OK, event is invalid
cl_int status = clWaitForEvents(1,&mX);
REPORT_OPENCL_STATUS(status);
return (status == CL_SUCCESS);
}
private:
Event(); // not implemented
Event(cl_event x) : mX(x) { }
// OpenCL handle (MAY BE 0)
cl_event mX;
friend class CommandQueue;
friend class EventList;
}; // class Event
} // namespace
#endif // CLEvent_h
|