MAutoCLEvent Class Reference

#include <MOpenCLAutoPtr.h>

Class Description

AutoPtr for cl_event objects.

cl_event objects in openCL are reference-counted objects. When created, a cl_event has a preexisting reference count of 1. An MAutoCLEvent object does not need to increment the reference count when it takes over ownership of a cl_event from OpenCL. An MAutoCLEvent object does need to increment the reference count of a cl_event object when the cl_event is shared between MAutoCLEvent objects.

Always use MAutoCLEvent objects in user code. Only use the raw cl_event handle when you use the OpenCL API.

Assignment or construction with a raw cl_event DOES NOT increment the reference count. Assignment or construction from another MAutoCLEvent DOES increment the reference count.

+ Examples:

Public Member Functions

 MAutoCLEvent ()
 Construct a NULL MAutoCLEvent.
 
 ~MAutoCLEvent ()
 Destructor.
 
 MAutoCLEvent (const MAutoCLEvent &other)
 The copy ctor increments the reference count of the cl_event. More...
 
MAutoCLEventoperator= (const MAutoCLEvent &other)
 The assignment operator increments the reference count of the cl_event. More...
 
 MAutoCLEvent (cl_event value, NoRef dummy)
 This ctor does not increment the reference count of value. More...
 
void attach (cl_event value)
 This method causes the "this" object to take over lifetime management for value. More...
 
cl_event detach ()
 This method causes the "this" object to stop managing the lifetime of its current cl_event. More...
 
void reset ()
 This method causes the "this" object to stop managing the lifetime of its current cl_event. More...
 
cl_event get () const
 This method returns the current cl_event whose lifetime is being managed by the "this" object. More...
 
bool isNull () const
 This method checks if the "this" object actually manages a non-null cl_event object. More...
 
const cl_event * getReadOnlyRef () const
 This method returns a const pointer to the cl_event whose lifetime is being managed by the "this" object. More...
 
cl_event * getReferenceForAssignment ()
 This method returns a pointer to the memory appropriate for storing a cl_event. More...
 
bool operator== (const MAutoCLEvent &other) const
 operator equal More...
 
bool operator== (cl_event other) const
 operator equal More...
 
bool operator! () const
 operator not More...
 
void swap (MAutoCLEvent &other)
 This method swaps the cl_event managed by the "this" object with the cl_event managed by the other object. More...
 
bool operator< (const MAutoCLEvent &other) const
 operator less than More...
 

Constructor & Destructor Documentation

MAutoCLEvent ( const MAutoCLEvent other)

The copy ctor increments the reference count of the cl_event.

Parameters
[in]otherThe MAutoCLEvent to be copied.
MAutoCLEvent ( cl_event  value,
NoRef  dummy 
)

This ctor does not increment the reference count of value.

The dummy parameter is included to prevent accidental use the ctor.

Parameters
[in]valueThe cl_event that the "this" object manages of the lifetime of.
[in]dummyA dummy parameter to make this ctor difficult to call by accident.

Member Function Documentation

MAutoCLEvent & operator= ( const MAutoCLEvent other)

The assignment operator increments the reference count of the cl_event.

Parameters
[in]otherThe MAutoCLEvent to be assigned to the "this" object.
void attach ( cl_event  value)

This method causes the "this" object to take over lifetime management for value.

The reference count of value is not modified by attach(). If "this" object already manages the lifetime of a cl_event object, the reference count of the old cl_event is decremented.

Parameters
[in]valueThe cl_event the "this" object should manage the lifetime of.
cl_event detach ( )

This method causes the "this" object to stop managing the lifetime of its current cl_event.

The reference count of the cl_event is not modified by detach().

Returns
The cl_event that was being managed by the "this" object.
void reset ( )

This method causes the "this" object to stop managing the lifetime of its current cl_event.

The reference count of the cl_event is decremented.

cl_event get ( ) const

This method returns the current cl_event whose lifetime is being managed by the "this" object.

The reference count of the cl_event is not modified by get().

Returns
The cl_event being managed by the "this" object.
+ Examples:
bool isNull ( ) const

This method checks if the "this" object actually manages a non-null cl_event object.

Returns
True if the "this" object manages a non-null cl_event object.
const cl_event * getReadOnlyRef ( ) const

This method returns a const pointer to the cl_event whose lifetime is being managed by the "this" object.

The reference count of the cl_event is not modified.

Returns
A pointer to the cl_event managed by the "this" object.
+ Examples:
cl_event * getReferenceForAssignment ( )

This method returns a pointer to the memory appropriate for storing a cl_event.

getReferenceForAssignment() decrements the reference count of the cl_event before returning, which means it is not safe to dereference the returned value. The "this" object manages the lifetime of the cl_event stored in the returned pointer.

Returns
A pointer to memory appropriate for storing a cl_event.
+ Examples:
bool operator== ( const MAutoCLEvent other) const

operator equal

Parameters
[in]otherThe MAutoCLEvent to compare with the "this" object.
Returns
True if the cl_event managed by the "this" object is the same as the cl_event managed by the other object.
bool operator== ( cl_event  other) const

operator equal

Parameters
[in]otherThe cl_event that compares with the "this" object.
Returns
True if the cl_event managed by the "this" object is other.
bool operator! ( ) const

operator not

Returns
True if the cl_event managed by the "this" object is NULL.
void swap ( MAutoCLEvent other)

This method swaps the cl_event managed by the "this" object with the cl_event managed by the other object.

swap() does not modify the reference counts of either cl_event object.

Parameters
[in]otherThe MAutoCLEvent to swap cl_event's with.
bool operator< ( const MAutoCLEvent other) const

operator less than

Parameters
[in]otherthe MAutoCLEvent with which the "this" object is compared.
Returns
True if the "this" object is arbitrarily less than the other object.

The documentation for this class was generated from the following files:
  • MOpenCLAutoPtr.h
  • MOpenCLAutoPtr.cpp