The std::async calls need a lock on them.
This commit is contained in:
parent
4b2ed2951e
commit
ea89e083dd
3 changed files with 9 additions and 3 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
|
||||
using std::string;
|
||||
using namespace fmt;
|
||||
|
@ -32,13 +33,15 @@ Builder::Builder(GUI &g, GameEngine &engine)
|
|||
config["build_cmd"].template get_to<string>(build_cmd);
|
||||
}
|
||||
|
||||
FILE *start_command(string &build_cmd) {
|
||||
FILE *Builder::start_command(string &build_cmd) {
|
||||
std::lock_guard<std::mutex> lock(fsm_mutex);
|
||||
FILE *build_out = popen(build_cmd.c_str(), "r");
|
||||
dbc::check(build_out != nullptr, "Failed to run command.");
|
||||
return build_out;
|
||||
}
|
||||
|
||||
string read_line(FILE *build_out, bool &done_out) {
|
||||
string Builder::read_line(FILE *build_out, bool &done_out) {
|
||||
std::lock_guard<std::mutex> lock(fsm_mutex);
|
||||
char buffer[BUF_MAX];
|
||||
char *res = fgets(buffer, BUF_MAX, build_out);
|
||||
done_out = res == nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue