| Index: src/utils/SkTaskGroup.h
|
| diff --git a/src/utils/SkTaskGroup.h b/src/utils/SkTaskGroup.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d9e6f597d05b173071acc1254d7045e553431fba
|
| --- /dev/null
|
| +++ b/src/utils/SkTaskGroup.h
|
| @@ -0,0 +1,36 @@
|
| +/*
|
| + * Copyright 2014 Google Inc.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#ifndef SkTaskGroup_DEFINED
|
| +#define SkTaskGroup_DEFINED
|
| +
|
| +#include "SkTypes.h"
|
| +#include "SkRunnable.h"
|
| +
|
| +class SkTaskGroup : SkNoncopyable {
|
| +public:
|
| + // Create one of these in main() to enable SkTaskGroups globally.
|
| + struct Enabler : SkNoncopyable {
|
| + explicit Enabler(int threads = 0); // Default is system-reported core count.
|
| + ~Enabler();
|
| + };
|
| +
|
| + SkTaskGroup();
|
| + ~SkTaskGroup() { this->wait(); }
|
| +
|
| + // Add a task to this SkTaskGroup. It will likely run() on another thread.
|
| + void add(SkRunnable*);
|
| +
|
| + // Block until all Tasks previously add()ed to this SkTaskGroup have run().
|
| + // You may safely reuse this SkTaskGroup after wait() returns.
|
| + void wait();
|
| +
|
| +private:
|
| + /*atomic*/ int32_t fPending;
|
| +};
|
| +
|
| +#endif//SkTaskGroup_DEFINED
|
|
|