2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkTaskGroup_DEFINED
9 #define SkTaskGroup_DEFINED
12 #include "SkRunnable.h"
14 class SkTaskGroup : SkNoncopyable {
16 // Create one of these in main() to enable SkTaskGroups globally.
17 struct Enabler : SkNoncopyable {
18 explicit Enabler(int threads = 0); // Default is system-reported core count.
23 ~SkTaskGroup() { this->wait(); }
25 // Add a task to this SkTaskGroup. It will likely run() on another thread.
26 void add(SkRunnable*);
28 // Block until all Tasks previously add()ed to this SkTaskGroup have run().
29 // You may safely reuse this SkTaskGroup after wait() returns.
33 /*atomic*/ int32_t fPending;
36 #endif//SkTaskGroup_DEFINED