FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
task_runner.hpp
Go to the documentation of this file.
1// Copyright 2024 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef TASK_RUNNER_HPP
5#define TASK_RUNNER_HPP
6
9
10namespace ftxui::task {
11
13 public:
14 TaskRunner();
16
17 // 現在のスレッドのタスクランナーを返します。
18 static auto Current() -> TaskRunner*;
19
20 /// タスクを即座に実行するようにスケジュールします。
21 auto PostTask(Task task) -> void;
22
23 /// 特定の期間の後に実行されるようにタスクをスケジュールします。
24 auto PostDelayedTask(Task task,
25 std::chrono::steady_clock::duration duration) -> void;
26
27 /// キュー内のタスクを実行し、次の遅延タスクが実行されるまでの遅延を返します。
28 auto RunUntilIdle() -> std::optional<std::chrono::steady_clock::duration>;
29
30 // キュー内のタスクを実行し、すべてのタスクが実行されるまでブロックします。
31 auto Run() -> void;
32
33 bool HasImmediateTasks() const { return queue_.HasImmediateTasks(); }
34
35 size_t ExecutedTasks() const { return executed_tasks_; }
36
37 private:
38 TaskRunner* previous_task_runner_ = nullptr;
39 TaskQueue queue_;
40 size_t executed_tasks_ = 0;
41};
42
43} // namespace ftxui::task
44
45#endif // TASK_RUNNER_HPP
bool HasImmediateTasks() const
static auto Current() -> TaskRunner *
auto PostTask(Task task) -> void
タスクを即座に実行するようにスケジュールします。
auto RunUntilIdle() -> std::optional< std::chrono::steady_clock::duration >
キュー内のタスクを実行し、次の遅延タスクが実行されるまでの遅延を返します。
auto PostDelayedTask(Task task, std::chrono::steady_clock::duration duration) -> void
特定の期間の後に実行されるようにタスクをスケジュールします。
size_t ExecutedTasks() const
std::function< void()> Task
タスクは作業の単位を表します。
bool HasImmediateTasks() const