forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
threads.cc
56 lines (41 loc) · 1.19 KB
/
threads.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/common/threads.h"
#include <utility>
namespace blink {
namespace {
Threads* g_threads = nullptr;
} // namespace
Threads::Threads() {}
Threads::Threads(ftl::RefPtr<ftl::TaskRunner> platform,
ftl::RefPtr<ftl::TaskRunner> gpu,
ftl::RefPtr<ftl::TaskRunner> ui,
ftl::RefPtr<ftl::TaskRunner> io)
: platform_(std::move(platform)),
gpu_(std::move(gpu)),
ui_(std::move(ui)),
io_(std::move(io)) {}
Threads::~Threads() {}
const ftl::RefPtr<ftl::TaskRunner>& Threads::Platform() {
return Get().platform_;
}
const ftl::RefPtr<ftl::TaskRunner>& Threads::Gpu() {
return Get().gpu_;
}
const ftl::RefPtr<ftl::TaskRunner>& Threads::UI() {
return Get().ui_;
}
const ftl::RefPtr<ftl::TaskRunner>& Threads::IO() {
return Get().io_;
}
const Threads& Threads::Get() {
FTL_CHECK(g_threads);
return *g_threads;
}
void Threads::Set(const Threads& threads) {
FTL_CHECK(!g_threads);
g_threads = new Threads();
*g_threads = threads;
}
} // namespace blink