FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
task_internal.hpp
Go to the documentation of this file.
1// Copyright 2024 Arthur Sonzogni. 保留所有權利。
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
Definition task.cpp:7