1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_FML_MEMORY_TASK_RUNNER_CHECKER_H_
6#define FLUTTER_FML_MEMORY_TASK_RUNNER_CHECKER_H_
7
8#include "flutter/fml/message_loop.h"
9#include "flutter/fml/task_runner.h"
10
11namespace fml {
12
13class TaskRunnerChecker final {
14 public:
15 TaskRunnerChecker();
16
17 ~TaskRunnerChecker();
18
19 bool RunsOnCreationTaskRunner() const;
20
21 static bool RunsOnTheSameThread(TaskQueueId queue_a, TaskQueueId queue_b);
22
23 private:
24 TaskQueueId initialized_queue_id_;
25
26 TaskQueueId InitTaskQueueId();
27};
28
29#if !defined(NDEBUG)
30#define FML_DECLARE_TASK_RUNNER_CHECKER(c) fml::TaskRunnerChecker c
31#define FML_DCHECK_TASK_RUNNER_IS_CURRENT(c) \
32 FML_DCHECK((c).RunsOnCreationTaskRunner())
33#else
34#define FML_DECLARE_TASK_RUNNER_CHECKER(c)
35#define FML_DCHECK_TASK_RUNNER_IS_CURRENT(c) ((void)0)
36#endif
37
38} // namespace fml
39
40#endif // FLUTTER_FML_MEMORY_THREAD_CHECKER_H_
41