Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions engine/src/flutter/shell/platform/windows/task_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ std::chrono::nanoseconds TaskRunner::ProcessTasks() {
// Calculate duration to sleep for on next iteration.
{
std::lock_guard<std::mutex> lock(task_queue_mutex_);
const auto next_wake = task_queue_.empty() ? TaskTimePoint::max()
: task_queue_.top().fire_time;

return std::min(next_wake - now, std::chrono::nanoseconds::max());
if (task_queue_.empty()) {
return std::chrono::nanoseconds::max();
} else {
return task_queue_.top().fire_time - now;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ class TestTaskRunnerWindow : public TaskRunnerWindow {
TestTaskRunnerWindow() : TaskRunnerWindow() {}
};

TEST(TaskRunnerTest, EmptyTaskRunnerReturnsNanSecondsMax) {
TaskRunner runner(MockGetCurrentTime, [](const FlutterTask*) {});
auto res = runner.ProcessTasks();
EXPECT_EQ(res, std::chrono::nanoseconds::max());
}

TEST(TaskRunnerTest, TaskRunnerWindowCoalescesWakeUpMessages) {
class Delegate : public TaskRunnerWindow::Delegate {
public:
Expand Down