FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
task_internal.hpp
浏览该文件的文档.
1// Copyright 2024 Arthur Sonzogni. All rights reserved.
2// 本源代码的使用受 MIT 许可证的约束,该许可证可在 LICENSE 文件中找到。
3#ifndef TASK_HPP
4#define TASK_HPP
5
6#include <chrono>
7#include <functional>
8#include <optional>
9
10namespace ftxui::task {
11
12/// 任务表示一个工作单元。
13using Task = std::function<void()>;
14
15/// PendingTask 表示一个计划在特定时间或尽快执行的任务。
17 // 即时任务:
18 PendingTask(Task t) : task(std::move(t)) {} // NOLINT
19
20 // 延迟任务,带有一个持续时间
21 PendingTask(Task t, std::chrono::steady_clock::duration duration)
22 : task(std::move(t)), time(std::chrono::steady_clock::now() + duration) {}
23
24 /// 要执行的任务。
26
27 /// 任务应该执行的时间。如果时间为空,则任务应尽快执行。
28 std::optional<std::chrono::steady_clock::time_point> time;
29
30 /// 按时间比较两个 PendingTask。
31 /// 如果两个任务都没有时间,则它们被认为是相等的。
32 bool operator<(const PendingTask& other) const;
33};
34
35} // namespace ftxui::task
36
37#endif // TASK_HPP_
std::function< void()> Task
任务表示一个工作单元。
PendingTask 表示一个计划在特定时间或尽快执行的任务。
PendingTask(Task t, std::chrono::steady_clock::duration duration)
Task task
要执行的任务。
std::optional< std::chrono::steady_clock::time_point > time
任务应该执行的时间。如果时间为空,则任务应尽快执行。
bool operator<(const PendingTask &other) const
定义 task.cpp:6