Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
task_runner_util.h
Go to the documentation of this file.
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_TASK_RUNNER_UTIL_H_
6#define FLUTTER_FML_TASK_RUNNER_UTIL_H_
7
8#include <functional>
9
12
13namespace fml {
14
15/// A BasicTaskRunner that posts tasks to another task runner.
16///
17/// This can be used to adapt an fml::RefPtr<fml::TaskRunner> to APIs that
18/// take a BasicTaskRunner that is not managed by fml::RefPtr.
20 public:
22
23 virtual ~WrapperBasicTaskRunner() = default;
24
25 void PostTask(const fml::closure& task) override;
26
27 private:
29
31};
32
33/// A BasicTaskRunner that wraps another task runner and takes a function
34/// that indicates whether that task runner is still usable.
35///
36/// Before each posted task is run, ConditionalBasicTaskRunner will call the
37/// is_usable function on the underlying task runner's thread. If is_usable
38/// returns false, then the task will not be executed.
40 public:
42 std::function<bool()> is_usable);
43
44 virtual ~ConditionalBasicTaskRunner() = default;
45
46 void PostTask(const fml::closure& task) override;
47
48 private:
50 const std::shared_ptr<std::function<bool()>> is_usable_;
51
53};
54
55} // namespace fml
56
57#endif // FLUTTER_FML_TASK_RUNNER_UTIL_H_
An interface over the ability to schedule tasks on a TaskRunner.
Definition task_runner.h:20
virtual ~ConditionalBasicTaskRunner()=default
void PostTask(const fml::closure &task) override
virtual ~WrapperBasicTaskRunner()=default
void PostTask(const fml::closure &task) override
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::function< void()> closure
Definition closure.h:14