mirror of
https://github.com/godotengine/godot.git
synced 2025-03-19 23:53:32 +08:00
Thread: Re-add <new>
include for std::hardware_destructive_interference_size
Somehow it would still build fine, but would crash when compiled with GCC 12.2 on Debian 12. Also re-add wrongly removed Mutex include from `thread_safe.h`, where it's used in macros. Add IWYU pragma comments to prevent it from mistakenly flagging those as unused.
This commit is contained in:
parent
2582793d40
commit
f2d4dac92e
@ -29,13 +29,13 @@
|
||||
/**************************************************************************/
|
||||
|
||||
#include "platform_config.h"
|
||||
#ifndef PLATFORM_THREAD_OVERRIDE // See details in thread.h
|
||||
|
||||
#ifndef PLATFORM_THREAD_OVERRIDE // See details in thread.h.
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef THREADS_ENABLED
|
||||
#include "core/object/script_language.h"
|
||||
#include "core/templates/safe_refcount.h"
|
||||
|
||||
SafeNumeric<uint64_t> Thread::id_counter(1); // The first value after .increment() is 2, hence by default the main thread ID should be 1.
|
||||
|
||||
|
@ -29,19 +29,28 @@
|
||||
/**************************************************************************/
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
// Define PLATFORM_THREAD_OVERRIDE in your platform's `platform_config.h`
|
||||
// to use a custom Thread implementation defined in `platform/[your_platform]/platform_thread.h`
|
||||
// Overriding the platform implementation is required in some proprietary platforms
|
||||
// to use a custom Thread implementation defined in `platform/[your_platform]/platform_thread.h`.
|
||||
// Overriding the Thread implementation is required in some proprietary platforms.
|
||||
|
||||
#ifdef PLATFORM_THREAD_OVERRIDE
|
||||
|
||||
#include "platform_thread.h"
|
||||
|
||||
#else
|
||||
|
||||
#ifndef THREAD_H
|
||||
#define THREAD_H
|
||||
|
||||
#include "core/templates/safe_refcount.h"
|
||||
#include "core/typedefs.h"
|
||||
|
||||
#ifdef THREADS_ENABLED
|
||||
|
||||
#include "core/templates/safe_refcount.h"
|
||||
|
||||
#include <new> // IWYU pragma: keep // For hardware interference size.
|
||||
|
||||
#ifdef MINGW_ENABLED
|
||||
#define MINGW_STDTHREAD_REDUNDANCY_WARNING
|
||||
#include "thirdparty/mingw-std-threads/mingw.thread.h"
|
||||
@ -53,8 +62,6 @@
|
||||
|
||||
class String;
|
||||
|
||||
#ifdef THREADS_ENABLED
|
||||
|
||||
class Thread {
|
||||
public:
|
||||
typedef void (*Callback)(void *p_userdata);
|
||||
@ -143,6 +150,8 @@ public:
|
||||
|
||||
#else // No threads.
|
||||
|
||||
class String;
|
||||
|
||||
class Thread {
|
||||
public:
|
||||
typedef void (*Callback)(void *p_userdata);
|
||||
|
@ -31,6 +31,8 @@
|
||||
#ifndef THREAD_SAFE_H
|
||||
#define THREAD_SAFE_H
|
||||
|
||||
#include "core/os/mutex.h" // IWYU pragma: keep // Used in macro.
|
||||
|
||||
#define _THREAD_SAFE_CLASS_ mutable Mutex _thread_safe_;
|
||||
#define _THREAD_SAFE_METHOD_ MutexLock _thread_safe_method_(_thread_safe_);
|
||||
#define _THREAD_SAFE_LOCK_ _thread_safe_.lock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user