diff options
author | Francisco Jerez <[email protected]> | 2015-06-09 22:52:25 +0300 |
---|---|---|
committer | Jan Vesely <[email protected]> | 2017-09-20 18:48:28 -0400 |
commit | 02f8ac6b70033a1b240d497c4664c359d2398cc3 (patch) | |
tree | 16d78dda1638bb7822ee440820ba293cbf0b5441 /src/gallium/state_trackers | |
parent | ae8c7c703bfd4199cc4caa1a1d1d6d9f0cde9b63 (diff) |
clover: Wrap event::wait_count in a method taking care of the required locking.
Acked-by: Aaron Watry <[email protected]>
Reviewed-by: Jan Vesely <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/clover/core/event.cpp | 19 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/event.hpp | 3 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/clover/core/event.cpp b/src/gallium/state_trackers/clover/core/event.cpp index 8275e16a4dd..4f8531e407e 100644 --- a/src/gallium/state_trackers/clover/core/event.cpp +++ b/src/gallium/state_trackers/clover/core/event.cpp @@ -27,7 +27,7 @@ using namespace clover; event::event(clover::context &ctx, const ref_vector<event> &deps, action action_ok, action action_fail) : - context(ctx), wait_count(1), _status(0), + context(ctx), _wait_count(1), _status(0), action_ok(action_ok), action_fail(action_fail) { for (auto &ev : deps) ev.chain(*this); @@ -41,7 +41,7 @@ event::trigger_self() { std::lock_guard<std::mutex> lock(mutex); std::vector<intrusive_ref<event>> evs; - if (!--wait_count) + if (!--_wait_count) std::swap(_chain, evs); return evs; @@ -81,10 +81,15 @@ event::abort(cl_int status) { ev.abort(status); } +unsigned +event::wait_count() const { + std::lock_guard<std::mutex> lock(mutex); + return _wait_count; +} + bool event::signalled() const { - std::lock_guard<std::mutex> lock(mutex); - return !wait_count; + return !wait_count(); } cl_int @@ -99,8 +104,8 @@ event::chain(event &ev) { std::unique_lock<std::mutex> lock_ev(ev.mutex, std::defer_lock); std::lock(lock, lock_ev); - if (wait_count) { - ev.wait_count++; + if (_wait_count) { + ev._wait_count++; _chain.push_back(ev); } ev.deps.push_back(*this); @@ -112,7 +117,7 @@ event::wait() const { ev.wait(); std::unique_lock<std::mutex> lock(mutex); - cv.wait(lock, [=]{ return !wait_count; }); + cv.wait(lock, [=]{ return !_wait_count; }); } hard_event::hard_event(command_queue &q, cl_command_type command, diff --git a/src/gallium/state_trackers/clover/core/event.hpp b/src/gallium/state_trackers/clover/core/event.hpp index 6469e483c73..53dac686f8e 100644 --- a/src/gallium/state_trackers/clover/core/event.hpp +++ b/src/gallium/state_trackers/clover/core/event.hpp @@ -85,8 +85,9 @@ namespace clover { private: std::vector<intrusive_ref<event>> trigger_self(); std::vector<intrusive_ref<event>> abort_self(cl_int status); + unsigned wait_count() const; - unsigned wait_count; + unsigned _wait_count; cl_int _status; action action_ok; action action_fail; |