You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Merge pull request #36556 from RandomShaper/rework_mutex
Reimplement `Mutex` with C++'s `<mutex>` (plus more)
This commit is contained in:
@@ -5554,7 +5554,7 @@ void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_err
|
||||
static void _execute_thread(void *p_ud) {
|
||||
|
||||
EditorNode::ExecuteThreadArgs *eta = (EditorNode::ExecuteThreadArgs *)p_ud;
|
||||
Error err = OS::get_singleton()->execute(eta->path, eta->args, true, NULL, &eta->output, &eta->exitcode, true, eta->execute_output_mutex);
|
||||
Error err = OS::get_singleton()->execute(eta->path, eta->args, true, NULL, &eta->output, &eta->exitcode, true, &eta->execute_output_mutex);
|
||||
print_verbose("Thread exit status: " + itos(eta->exitcode));
|
||||
if (err != OK) {
|
||||
eta->exitcode = err;
|
||||
@@ -5574,7 +5574,6 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p
|
||||
ExecuteThreadArgs eta;
|
||||
eta.path = p_path;
|
||||
eta.args = p_arguments;
|
||||
eta.execute_output_mutex = Mutex::create();
|
||||
eta.exitcode = 255;
|
||||
eta.done = false;
|
||||
|
||||
@@ -5585,20 +5584,20 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p
|
||||
ERR_FAIL_COND_V(!eta.execute_output_thread, 0);
|
||||
|
||||
while (!eta.done) {
|
||||
eta.execute_output_mutex->lock();
|
||||
if (prev_len != eta.output.length()) {
|
||||
String to_add = eta.output.substr(prev_len, eta.output.length());
|
||||
prev_len = eta.output.length();
|
||||
execute_outputs->add_text(to_add);
|
||||
Main::iteration();
|
||||
{
|
||||
MutexLock lock(eta.execute_output_mutex);
|
||||
if (prev_len != eta.output.length()) {
|
||||
String to_add = eta.output.substr(prev_len, eta.output.length());
|
||||
prev_len = eta.output.length();
|
||||
execute_outputs->add_text(to_add);
|
||||
Main::iteration();
|
||||
}
|
||||
}
|
||||
eta.execute_output_mutex->unlock();
|
||||
OS::get_singleton()->delay_usec(1000);
|
||||
}
|
||||
|
||||
Thread::wait_to_finish(eta.execute_output_thread);
|
||||
memdelete(eta.execute_output_thread);
|
||||
memdelete(eta.execute_output_mutex);
|
||||
execute_outputs->add_text("\nExit Code: " + itos(eta.exitcode));
|
||||
|
||||
if (p_close_on_errors && eta.exitcode != 0) {
|
||||
|
||||
Reference in New Issue
Block a user