Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Unified Diff: src/utils/SkTaskGroup.cpp

Issue 556223003: Let SkTaskGroup work synchronously if no one created an SkTaskGroup::Enabler. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkTaskGroup.cpp
diff --git a/src/utils/SkTaskGroup.cpp b/src/utils/SkTaskGroup.cpp
index e7de6becd81ca55ef5040822d44d476b19e75358..7449eb65655c4231863c323318717a8af28b388c 100644
--- a/src/utils/SkTaskGroup.cpp
+++ b/src/utils/SkTaskGroup.cpp
@@ -23,12 +23,17 @@ namespace {
class ThreadPool : SkNoncopyable {
public:
static void Add(SkRunnable* task, int32_t* pending) {
- SkASSERT(gGlobal); // If this fails, see SkTaskGroup::Enabler.
+ if (!gGlobal) { // If we have no threads, run synchronously.
+ return task->run();
+ }
gGlobal->add(task, pending);
}
static void Wait(int32_t* pending) {
- SkASSERT(gGlobal); // If this fails, see SkTaskGroup::Enabler.
+ if (!gGlobal) { // If we have no threads, the work must already be done.
+ SkASSERT(*pending == 0);
+ return;
+ }
while (sk_acquire_load(pending) > 0) { // Pairs with sk_atomic_dec here or in Loop.
// Lend a hand until our SkTaskGroup of interest is done.
Work work;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698