#include <background_command_task.h>
Classes | |
| struct | Snapshot |
Public Member Functions | |
| BackgroundCommandTask ()=default | |
| ~BackgroundCommandTask () | |
| BackgroundCommandTask (const BackgroundCommandTask &)=delete | |
| BackgroundCommandTask & | operator= (const BackgroundCommandTask &)=delete |
| absl::Status | Start (const std::string &command, const std::string &directory) |
| void | Cancel () |
| Snapshot | GetSnapshot () const |
| absl::Status | Wait () |
Private Member Functions | |
| void | WorkerMain (std::string command, std::string directory) |
| void | AppendOutput (const char *data, size_t size) |
| void | Finalize (absl::Status status, int exit_code) |
| void | JoinIfNeeded () |
Static Private Member Functions | |
| static std::string | ComputeOutputTail (const std::string &output) |
Private Attributes | |
| std::mutex | mutex_ |
| std::thread | worker_ |
| bool | started_ = false |
| bool | running_ = false |
| bool | finished_ = false |
| bool | cancel_requested_ = false |
| int | exit_code_ = -1 |
| int | child_pid_ = -1 |
| std::string | command_ |
| std::string | directory_ |
| std::string | output_ |
| std::string | output_tail_ |
| absl::Status | status_ = absl::UnknownError("Task not started") |
Definition at line 12 of file background_command_task.h.
|
default |
| yaze::editor::BackgroundCommandTask::~BackgroundCommandTask | ( | ) |
Definition at line 42 of file background_command_task.cc.
References Cancel(), and JoinIfNeeded().

|
delete |
|
delete |
| absl::Status yaze::editor::BackgroundCommandTask::Start | ( | const std::string & | command, |
| const std::string & | directory ) |
Definition at line 47 of file background_command_task.cc.
References cancel_requested_, child_pid_, command_, directory_, exit_code_, finished_, JoinIfNeeded(), mutex_, output_, output_tail_, running_, started_, status_, worker_, and WorkerMain().
Referenced by yaze::editor::EditorManager::RunProjectBuildCommand().

| void yaze::editor::BackgroundCommandTask::Cancel | ( | ) |
Definition at line 76 of file background_command_task.cc.
References cancel_requested_, child_pid_, and mutex_.
Referenced by ~BackgroundCommandTask().
| BackgroundCommandTask::Snapshot yaze::editor::BackgroundCommandTask::GetSnapshot | ( | ) | const |
Definition at line 93 of file background_command_task.cc.
References cancel_requested_, command_, directory_, exit_code_, finished_, mutex_, output_, output_tail_, running_, started_, and status_.
Referenced by yaze::editor::EditorManager::RunProjectBuildCommand().
| absl::Status yaze::editor::BackgroundCommandTask::Wait | ( | ) |
Definition at line 108 of file background_command_task.cc.
References JoinIfNeeded(), mutex_, and status_.
Referenced by yaze::editor::EditorManager::RunProjectBuildCommand().

|
private |
Definition at line 114 of file background_command_task.cc.
References AppendOutput(), cancel_requested_, child_pid_, Finalize(), and mutex_.
Referenced by Start().

|
private |
Definition at line 234 of file background_command_task.cc.
References ComputeOutputTail(), mutex_, output_, and output_tail_.
Referenced by WorkerMain().

|
private |
Definition at line 240 of file background_command_task.cc.
References ComputeOutputTail(), exit_code_, finished_, mutex_, output_, output_tail_, running_, and status_.
Referenced by WorkerMain().

|
private |
Definition at line 249 of file background_command_task.cc.
References worker_.
Referenced by Start(), Wait(), and ~BackgroundCommandTask().
|
staticprivate |
Definition at line 255 of file background_command_task.cc.
Referenced by AppendOutput(), and Finalize().
|
mutableprivate |
Definition at line 47 of file background_command_task.h.
Referenced by AppendOutput(), Cancel(), Finalize(), GetSnapshot(), Start(), Wait(), and WorkerMain().
|
private |
Definition at line 48 of file background_command_task.h.
Referenced by JoinIfNeeded(), and Start().
|
private |
Definition at line 49 of file background_command_task.h.
Referenced by GetSnapshot(), and Start().
|
private |
Definition at line 50 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 51 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 52 of file background_command_task.h.
Referenced by Cancel(), GetSnapshot(), Start(), and WorkerMain().
|
private |
Definition at line 53 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 54 of file background_command_task.h.
Referenced by Cancel(), Start(), and WorkerMain().
|
private |
Definition at line 55 of file background_command_task.h.
Referenced by GetSnapshot(), and Start().
|
private |
Definition at line 56 of file background_command_task.h.
Referenced by GetSnapshot(), and Start().
|
private |
Definition at line 57 of file background_command_task.h.
Referenced by AppendOutput(), Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 58 of file background_command_task.h.
Referenced by AppendOutput(), Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 59 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), Start(), and Wait().