summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/clover/api/event.cpp8
-rw-r--r--src/gallium/state_trackers/clover/core/event.cpp2
-rw-r--r--src/gallium/state_trackers/clover/core/event.hpp4
-rw-r--r--src/gallium/state_trackers/clover/core/platform.hpp4
-rw-r--r--src/gallium/state_trackers/clover/core/queue.hpp4
-rw-r--r--src/gallium/state_trackers/clover/util/pointer.hpp53
6 files changed, 45 insertions, 30 deletions
diff --git a/src/gallium/state_trackers/clover/api/event.cpp b/src/gallium/state_trackers/clover/api/event.cpp
index 1aff2c50238..05534c74c99 100644
--- a/src/gallium/state_trackers/clover/api/event.cpp
+++ b/src/gallium/state_trackers/clover/api/event.cpp
@@ -72,7 +72,7 @@ clWaitForEvents(cl_uint num_evs, const cl_event *d_evs) try {
// Create a temporary soft event that depends on all the events in
// the wait list
- ref_ptr<soft_event> sev =
+ intrusive_ptr<soft_event> sev =
transfer(new soft_event(evs.front().ctx, evs, true));
// ...and wait on it.
@@ -132,7 +132,7 @@ clSetEventCallback(cl_event d_ev, cl_int type,
// Create a temporary soft event that depends on ev, with
// pfn_notify as completion action.
- ref_ptr<soft_event> sev = transfer(
+ intrusive_ptr<soft_event> sev = transfer(
new soft_event(ev.ctx, { ev }, true,
[=, &ev](event &) {
ev.wait();
@@ -206,7 +206,7 @@ clEnqueueWaitForEvents(cl_command_queue d_q, cl_uint num_evs,
// Create a hard event that depends on the events in the wait list:
// subsequent commands in the same queue will be implicitly
// serialized with respect to it -- hard events always are.
- ref_ptr<hard_event> hev = transfer(new hard_event(q, 0, evs));
+ intrusive_ptr<hard_event> hev = transfer(new hard_event(q, 0, evs));
return CL_SUCCESS;
@@ -262,7 +262,7 @@ clFinish(cl_command_queue d_q) try {
// Create a temporary hard event -- it implicitly depends on all
// the previously queued hard events.
- ref_ptr<hard_event> hev = transfer(new hard_event(q, 0, { }));
+ intrusive_ptr<hard_event> hev = transfer(new hard_event(q, 0, { }));
// And wait on it.
hev->wait();
diff --git a/src/gallium/state_trackers/clover/core/event.cpp b/src/gallium/state_trackers/clover/core/event.cpp
index 97f56357566..3f3e05e289a 100644
--- a/src/gallium/state_trackers/clover/core/event.cpp
+++ b/src/gallium/state_trackers/clover/core/event.cpp
@@ -186,7 +186,7 @@ soft_event::status() const {
return _status;
else if (!signalled() ||
- any_of([](const ref_ptr<event> &ev) {
+ any_of([](const intrusive_ptr<event> &ev) {
return ev->status() != CL_COMPLETE;
}, deps))
return CL_SUBMITTED;
diff --git a/src/gallium/state_trackers/clover/core/event.hpp b/src/gallium/state_trackers/clover/core/event.hpp
index 05bdd2f961f..123304bacc3 100644
--- a/src/gallium/state_trackers/clover/core/event.hpp
+++ b/src/gallium/state_trackers/clover/core/event.hpp
@@ -76,13 +76,13 @@ namespace clover {
void chain(event *ev);
cl_int _status;
- std::vector<ref_ptr<event>> deps;
+ std::vector<intrusive_ptr<event>> deps;
private:
unsigned wait_count;
action action_ok;
action action_fail;
- std::vector<ref_ptr<event>> _chain;
+ std::vector<intrusive_ptr<event>> _chain;
};
///
diff --git a/src/gallium/state_trackers/clover/core/platform.hpp b/src/gallium/state_trackers/clover/core/platform.hpp
index c16229a7512..bcc8e0c1cb5 100644
--- a/src/gallium/state_trackers/clover/core/platform.hpp
+++ b/src/gallium/state_trackers/clover/core/platform.hpp
@@ -32,7 +32,7 @@
namespace clover {
class platform : public _cl_platform_id,
public adaptor_range<
- derefs, std::vector<ref_ptr<device>> &> {
+ derefs, std::vector<intrusive_ptr<device>> &> {
public:
platform();
@@ -41,7 +41,7 @@ namespace clover {
operator=(const platform &platform) = delete;
protected:
- std::vector<ref_ptr<device>> devs;
+ std::vector<intrusive_ptr<device>> devs;
};
}
diff --git a/src/gallium/state_trackers/clover/core/queue.hpp b/src/gallium/state_trackers/clover/core/queue.hpp
index e3c4ceb7744..81b9781cf47 100644
--- a/src/gallium/state_trackers/clover/core/queue.hpp
+++ b/src/gallium/state_trackers/clover/core/queue.hpp
@@ -69,9 +69,7 @@ namespace clover {
cl_command_queue_properties _props;
pipe_context *pipe;
-
- typedef ref_ptr<hard_event> event_ptr;
- std::deque<event_ptr> queued_events;
+ std::deque<intrusive_ptr<hard_event>> queued_events;
};
}
diff --git a/src/gallium/state_trackers/clover/util/pointer.hpp b/src/gallium/state_trackers/clover/util/pointer.hpp
index f0c5b1618a5..b7a633b523c 100644
--- a/src/gallium/state_trackers/clover/util/pointer.hpp
+++ b/src/gallium/state_trackers/clover/util/pointer.hpp
@@ -57,35 +57,43 @@ namespace clover {
/// clover::ref_counter interface.
///
template<typename T>
- class ref_ptr {
+ class intrusive_ptr {
public:
- ref_ptr(T *q = NULL) : p(NULL) {
- reset(q);
+ intrusive_ptr(T *q = NULL) : p(q) {
+ if (p)
+ p->retain();
}
- ref_ptr(const ref_ptr<T> &ref) : p(NULL) {
- reset(ref.p);
+ intrusive_ptr(const intrusive_ptr &ptr) :
+ intrusive_ptr(ptr.p) {
}
- ~ref_ptr() {
- reset(NULL);
+ intrusive_ptr(intrusive_ptr &&ptr) :
+ p(ptr.p) {
+ ptr.p = NULL;
}
- void
- reset(T *q = NULL) {
- if (q)
- q->retain();
+ ~intrusive_ptr() {
if (p && p->release())
delete p;
- p = q;
}
- ref_ptr &
- operator=(const ref_ptr &ref) {
- reset(ref.p);
+ intrusive_ptr &
+ operator=(intrusive_ptr ptr) {
+ std::swap(ptr.p, p);
return *this;
}
+ bool
+ operator==(const intrusive_ptr &ref) const {
+ return p == ref.p;
+ }
+
+ bool
+ operator!=(const intrusive_ptr &ref) const {
+ return p != ref.p;
+ }
+
T &
operator*() const {
return *p;
@@ -96,22 +104,31 @@ namespace clover {
return p;
}
+ T *
+ operator()() const {
+ return p;
+ }
+
explicit operator bool() const {
return p;
}
+ explicit operator T *() const {
+ return p;
+ }
+
private:
T *p;
};
///
/// Transfer the caller's ownership of a reference-counted object
- /// to a clover::ref_ptr smart pointer.
+ /// to a clover::intrusive_ptr smart pointer.
///
template<typename T>
- inline ref_ptr<T>
+ inline intrusive_ptr<T>
transfer(T *p) {
- ref_ptr<T> ref { p };
+ intrusive_ptr<T> ref { p };
p->release();
return ref;
}