You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Modernize Mutex
- Based on C++11's `mutex` - No more need to allocate-deallocate or check for null - No pointer anymore, just a member variable - Platform-specific implementations no longer needed - Simpler for `NO_THREADS` - `BinaryMutex` added for special cases as the non-recursive version - `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`. - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
#include "core/project_settings.h"
|
||||
#include "drivers/unix/dir_access_unix.h"
|
||||
#include "drivers/unix/file_access_unix.h"
|
||||
#include "drivers/unix/mutex_posix.h"
|
||||
#include "drivers/unix/net_socket_posix.h"
|
||||
#include "drivers/unix/semaphore_posix.h"
|
||||
#include "drivers/unix/thread_posix.h"
|
||||
@@ -63,6 +62,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/// Clock Setup function (used by get_ticks_usec)
|
||||
@@ -122,13 +122,11 @@ void OS_Unix::initialize_core() {
|
||||
#ifdef NO_THREADS
|
||||
ThreadDummy::make_default();
|
||||
SemaphoreDummy::make_default();
|
||||
MutexDummy::make_default();
|
||||
#else
|
||||
ThreadPosix::make_default();
|
||||
#if !defined(OSX_ENABLED) && !defined(IPHONE_ENABLED)
|
||||
SemaphorePosix::make_default();
|
||||
#endif
|
||||
MutexPosix::make_default();
|
||||
#endif
|
||||
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
|
||||
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
|
||||
@@ -307,13 +305,9 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
|
||||
|
||||
while (fgets(buf, 65535, f)) {
|
||||
|
||||
if (p_pipe_mutex) {
|
||||
p_pipe_mutex->lock();
|
||||
}
|
||||
p_pipe_mutex->lock();
|
||||
(*r_pipe) += String::utf8(buf);
|
||||
if (p_pipe_mutex) {
|
||||
p_pipe_mutex->unlock();
|
||||
}
|
||||
p_pipe_mutex->unlock();
|
||||
}
|
||||
int rv = pclose(f);
|
||||
if (r_exitcode)
|
||||
|
||||
Reference in New Issue
Block a user