forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreads.h
48 lines (37 loc) · 1.41 KB
/
threads.h
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
// 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.
#ifndef FLUTTER_COMMON_THREADS_H_
#define FLUTTER_COMMON_THREADS_H_
#include "lib/fxl/tasks/task_runner.h"
#define ASSERT_IS_PLATFORM_THREAD \
FXL_DCHECK(::blink::Threads::Platform()->RunsTasksOnCurrentThread());
#define ASSERT_IS_GPU_THREAD \
FXL_DCHECK(::blink::Threads::Gpu()->RunsTasksOnCurrentThread());
#define ASSERT_IS_UI_THREAD \
FXL_DCHECK(::blink::Threads::UI()->RunsTasksOnCurrentThread());
#define ASSERT_IS_IO_THREAD \
FXL_DCHECK(::blink::Threads::IO()->RunsTasksOnCurrentThread());
namespace blink {
class Threads {
public:
Threads();
Threads(fxl::RefPtr<fxl::TaskRunner> platform,
fxl::RefPtr<fxl::TaskRunner> gpu,
fxl::RefPtr<fxl::TaskRunner> ui,
fxl::RefPtr<fxl::TaskRunner> io);
~Threads();
static const fxl::RefPtr<fxl::TaskRunner>& Platform();
static const fxl::RefPtr<fxl::TaskRunner>& Gpu();
static const fxl::RefPtr<fxl::TaskRunner>& UI();
static const fxl::RefPtr<fxl::TaskRunner>& IO();
static void Set(const Threads& settings);
private:
static const Threads& Get();
fxl::RefPtr<fxl::TaskRunner> platform_;
fxl::RefPtr<fxl::TaskRunner> gpu_;
fxl::RefPtr<fxl::TaskRunner> ui_;
fxl::RefPtr<fxl::TaskRunner> io_;
};
} // namespace blink
#endif // FLUTTER_COMMON_THREADS_H_