aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkTaskGroup.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-08-24 11:17:55 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-24 15:37:36 +0000
commitf3c99eecc07a0ac64dc8e796c05fa6df71ea1119 (patch)
treef6bdf529ef2147c3ed501c7ad7529c9aca377d56 /src/core/SkTaskGroup.cpp
parent76323bc0615044a5921afef0e19a350f3d04ffe0 (diff)
add SkTaskGroup::done()
This lets you check if the work's done without blocking. Seems handy. Change-Id: Ie27c7b6fe0d01262b6a777abbc18b0de108641c0 Reviewed-on: https://skia-review.googlesource.com/38120 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkTaskGroup.cpp')
-rw-r--r--src/core/SkTaskGroup.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/SkTaskGroup.cpp b/src/core/SkTaskGroup.cpp
index 9469b8c1ce..c7927db5ba 100644
--- a/src/core/SkTaskGroup.cpp
+++ b/src/core/SkTaskGroup.cpp
@@ -29,12 +29,16 @@ void SkTaskGroup::batch(int N, std::function<void(int)> fn) {
}
}
+bool SkTaskGroup::done() const {
+ return fPending.load(std::memory_order_acquire) == 0;
+}
+
void SkTaskGroup::wait() {
// Actively help the executor do work until our task group is done.
// This lets SkTaskGroups nest arbitrarily deep on a single SkExecutor:
// no thread ever blocks waiting for others to do its work.
// (We may end up doing work that's not part of our task group. That's fine.)
- while (fPending.load(std::memory_order_acquire) > 0) {
+ while (!this->done()) {
fExecutor.borrow();
}
}