2018-11-07 12:24:35 -08:00
|
|
|
// Copyright 2013 The Flutter Authors. All rights reserved.
|
2017-03-20 13:41:41 -07:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
#ifndef FLUTTER_FML_TASK_RUNNER_H_
|
|
|
|
|
#define FLUTTER_FML_TASK_RUNNER_H_
|
|
|
|
|
|
2018-07-26 12:49:34 -07:00
|
|
|
#include "flutter/fml/closure.h"
|
2018-04-21 20:50:03 -07:00
|
|
|
#include "flutter/fml/macros.h"
|
2018-07-26 12:49:34 -07:00
|
|
|
#include "flutter/fml/memory/ref_counted.h"
|
|
|
|
|
#include "flutter/fml/memory/ref_ptr.h"
|
2019-07-12 16:55:33 -07:00
|
|
|
#include "flutter/fml/message_loop_task_queues.h"
|
2018-07-26 12:49:34 -07:00
|
|
|
#include "flutter/fml/time/time_point.h"
|
2017-03-20 13:41:41 -07:00
|
|
|
|
|
|
|
|
namespace fml {
|
|
|
|
|
|
|
|
|
|
class MessageLoopImpl;
|
|
|
|
|
|
2018-07-26 12:49:34 -07:00
|
|
|
class TaskRunner : public fml::RefCountedThreadSafe<TaskRunner> {
|
2017-03-20 13:41:41 -07:00
|
|
|
public:
|
2019-03-27 16:16:59 -07:00
|
|
|
virtual ~TaskRunner();
|
|
|
|
|
|
2019-11-22 12:20:02 -08:00
|
|
|
virtual void PostTask(const fml::closure& task);
|
2017-03-20 13:41:41 -07:00
|
|
|
|
2019-11-22 12:20:02 -08:00
|
|
|
virtual void PostTaskForTime(const fml::closure& task,
|
|
|
|
|
fml::TimePoint target_time);
|
2017-03-20 13:41:41 -07:00
|
|
|
|
2019-11-22 12:20:02 -08:00
|
|
|
virtual void PostDelayedTask(const fml::closure& task, fml::TimeDelta delay);
|
2017-03-20 13:41:41 -07:00
|
|
|
|
2018-08-01 14:18:33 -07:00
|
|
|
virtual bool RunsTasksOnCurrentThread();
|
|
|
|
|
|
2019-07-12 16:55:33 -07:00
|
|
|
virtual TaskQueueId GetTaskQueueId();
|
|
|
|
|
|
2018-07-26 12:49:34 -07:00
|
|
|
static void RunNowOrPostTask(fml::RefPtr<fml::TaskRunner> runner,
|
2019-11-22 12:20:02 -08:00
|
|
|
const fml::closure& task);
|
2018-04-13 13:48:15 -07:00
|
|
|
|
2018-08-01 14:18:33 -07:00
|
|
|
protected:
|
2018-07-26 12:49:34 -07:00
|
|
|
TaskRunner(fml::RefPtr<MessageLoopImpl> loop);
|
2017-03-20 13:41:41 -07:00
|
|
|
|
2018-08-01 14:18:33 -07:00
|
|
|
private:
|
|
|
|
|
fml::RefPtr<MessageLoopImpl> loop_;
|
2017-03-20 13:41:41 -07:00
|
|
|
|
2018-07-26 12:49:34 -07:00
|
|
|
FML_FRIEND_MAKE_REF_COUNTED(TaskRunner);
|
|
|
|
|
FML_FRIEND_REF_COUNTED_THREAD_SAFE(TaskRunner);
|
2018-04-21 20:50:03 -07:00
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(TaskRunner);
|
2017-03-20 13:41:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace fml
|
|
|
|
|
|
|
|
|
|
#endif // FLUTTER_FML_TASK_RUNNER_H_
|