Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
core
SkTaskGroup.h
Go to the documentation of this file.
1
/*
2
* Copyright 2014 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#ifndef SkTaskGroup_DEFINED
9
#define SkTaskGroup_DEFINED
10
11
#include "
include/core/SkExecutor.h
"
12
#include "
include/core/SkTypes.h
"
13
#include "
include/private/base/SkNoncopyable.h
"
14
15
#include <atomic>
16
#include <cstdint>
17
#include <functional>
18
#include <memory>
19
20
class
SkTaskGroup
:
SkNoncopyable
{
21
public
:
22
// Tasks added to this SkTaskGroup will run on its executor.
23
explicit
SkTaskGroup
(
SkExecutor
& executor =
SkExecutor::GetDefault
());
24
~SkTaskGroup
() { this->
wait
(); }
25
26
// Add a task to this SkTaskGroup.
27
void
add
(std::function<
void
(
void
)> fn);
28
29
// Add a batch of N tasks, all calling fn with different arguments.
30
void
batch
(
int
N
, std::function<
void
(
int
)> fn);
31
32
// Returns true if all Tasks previously add()ed to this SkTaskGroup have run.
33
// It is safe to reuse this SkTaskGroup once done().
34
bool
done
()
const
;
35
36
// Block until done().
37
void
wait
();
38
39
// A convenience for testing tools.
40
// Creates and owns a thread pool, and passes it to SkExecutor::SetDefault().
41
struct
Enabler
{
42
explicit
Enabler
(
int
threads = -1);
// -1 -> num_cores, 0 -> noop
43
std::unique_ptr<SkExecutor>
fThreadPool
;
44
};
45
46
private
:
47
std::atomic<int32_t> fPending;
48
SkExecutor
& fExecutor;
49
};
50
51
#endif
//SkTaskGroup_DEFINED
SkExecutor.h
SkNoncopyable.h
SkTypes.h
N
#define N
Definition
beziers.cpp:19
SkExecutor
Definition
SkExecutor.h:15
SkExecutor::GetDefault
static SkExecutor & GetDefault()
Definition
SkExecutor.cpp:50
SkNoncopyable
Definition
SkNoncopyable.h:18
SkTaskGroup
Definition
SkTaskGroup.h:20
SkTaskGroup::batch
void batch(int N, std::function< void(int)> fn)
Definition
SkTaskGroup.cpp:24
SkTaskGroup::add
void add(std::function< void(void)> fn)
Definition
SkTaskGroup.cpp:16
SkTaskGroup::done
bool done() const
Definition
SkTaskGroup.cpp:35
SkTaskGroup::~SkTaskGroup
~SkTaskGroup()
Definition
SkTaskGroup.h:24
SkTaskGroup::wait
void wait()
Definition
SkTaskGroup.cpp:39
SkTaskGroup::Enabler
Definition
SkTaskGroup.h:41
SkTaskGroup::Enabler::fThreadPool
std::unique_ptr< SkExecutor > fThreadPool
Definition
SkTaskGroup.h:43
Generated on Fri Apr 26 2024 06:16:49 for Flutter Engine by
1.9.8