FTXUI 7.0.3
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, std::chrono::steady_clock::duration duration)
25 -> void;
26
27 /// キュー内のタスクを実行し、次の遅延タスクが実行可能になるまでの
28 /// 遅延を返します。
29 auto RunUntilIdle() -> std::optional<std::chrono::steady_clock::duration>;
30
31 // キュー内のタスクを実行し、すべてのタスクが実行されるまでブロックする。
32 auto Run() -> void;
33
34 bool HasImmediateTasks() const { return queue_.HasImmediateTasks(); }
35
36 size_t ExecutedTasks() const { return executed_tasks_; }
37
38 private:
39 TaskRunner* previous_task_runner_ = nullptr;
40 TaskQueue queue_;
41 size_t executed_tasks_ = 0;
42};
43
44} // namespace ftxui::task
45
46#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
タスクは作業の単位を表します。
auto HasImmediateTasks() const -> bool