Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::TimerThread Class Reference

#include <task_runner_window.h>

Public Member Functions

 TimerThread (std::function< void()> callback)
 
void Start ()
 
void Stop ()
 
 ~TimerThread ()
 
void ScheduleAt (std::chrono::time_point< std::chrono::high_resolution_clock > time_point)
 

Detailed Description

Definition at line 24 of file task_runner_window.h.

Constructor & Destructor Documentation

◆ TimerThread()

flutter::TimerThread::TimerThread ( std::function< void()>  callback)
explicit

Definition at line 18 of file task_runner_window.cc.

19 : callback_(std::move(callback)),
20 next_fire_time_(
21 std::chrono::time_point<std::chrono::high_resolution_clock>::max()) {}
FlutterDesktopBinaryReply callback

◆ ~TimerThread()

flutter::TimerThread::~TimerThread ( )

Definition at line 41 of file task_runner_window.cc.

41 {
42 // Ensure that Stop() has been called if Start() has been called.
43 FML_DCHECK(callback_ == nullptr || !thread_);
44}
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK.

Member Function Documentation

◆ ScheduleAt()

void flutter::TimerThread::ScheduleAt ( std::chrono::time_point< std::chrono::high_resolution_clock >  time_point)

Definition at line 49 of file task_runner_window.cc.

50 {
51 std::lock_guard<std::mutex> lock(mutex_);
52 if (time_point < next_fire_time_) {
53 next_fire_time_ = time_point;
54 }
55 ++schedule_counter_;
56 cv_.notify_all();
57}

◆ Start()

void flutter::TimerThread::Start ( )

Definition at line 23 of file task_runner_window.cc.

23 {
24 FML_DCHECK(!thread_);
25 thread_ =
26 std::make_optional<std::thread>(&TimerThread::TimerThreadMain, this);
27}

References FML_DCHECK.

Referenced by flutter::testing::TEST().

◆ Stop()

void flutter::TimerThread::Stop ( )

Definition at line 29 of file task_runner_window.cc.

29 {
30 if (!thread_) {
31 return;
32 }
33 {
34 std::lock_guard<std::mutex> lock(mutex_);
35 callback_ = nullptr;
36 }
37 cv_.notify_all();
38 thread_->join();
39}

The documentation for this class was generated from the following files: