#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, const std::map< std::string, std::string > &environment={}) |
| void | Cancel () |
| Snapshot | GetSnapshot () const |
| absl::Status | Wait () |
Private Member Functions | |
| void | WorkerMain (std::string command, std::string directory, std::vector< std::string > environment) |
| 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 14 of file background_command_task.h.
|
default |
| yaze::editor::BackgroundCommandTask::~BackgroundCommandTask | ( | ) |
Definition at line 187 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, | ||
| const std::map< std::string, std::string > & | environment = {} ) |
Definition at line 192 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 240 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 257 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 272 of file background_command_task.cc.
References JoinIfNeeded(), mutex_, and status_.
Referenced by yaze::editor::EditorManager::RunProjectBuildCommand().

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

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

|
private |
Definition at line 770 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 779 of file background_command_task.cc.
References worker_.
Referenced by Start(), Wait(), and ~BackgroundCommandTask().
|
staticprivate |
Definition at line 785 of file background_command_task.cc.
Referenced by AppendOutput(), and Finalize().
|
mutableprivate |
Definition at line 58 of file background_command_task.h.
Referenced by AppendOutput(), Cancel(), Finalize(), GetSnapshot(), Start(), Wait(), and WorkerMain().
|
private |
Definition at line 59 of file background_command_task.h.
Referenced by JoinIfNeeded(), and Start().
|
private |
Definition at line 60 of file background_command_task.h.
Referenced by GetSnapshot(), and Start().
|
private |
Definition at line 61 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 62 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 63 of file background_command_task.h.
Referenced by Cancel(), GetSnapshot(), Start(), and WorkerMain().
|
private |
Definition at line 64 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 65 of file background_command_task.h.
Referenced by Cancel(), Start(), and WorkerMain().
|
private |
Definition at line 66 of file background_command_task.h.
Referenced by GetSnapshot(), and Start().
|
private |
Definition at line 67 of file background_command_task.h.
Referenced by GetSnapshot(), and Start().
|
private |
Definition at line 68 of file background_command_task.h.
Referenced by AppendOutput(), Finalize(), GetSnapshot(), and Start().
|
private |
Definition at line 69 of file background_command_task.h.
Referenced by AppendOutput(), Finalize(), GetSnapshot(), Start(), and WorkerMain().
|
private |
Definition at line 70 of file background_command_task.h.
Referenced by Finalize(), GetSnapshot(), Start(), and Wait().