Skip to content

Commit f2d4dac

Browse files
committed
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.
1 parent 2582793 commit f2d4dac

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

core/os/thread.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
/**************************************************************************/
3030

3131
#include "platform_config.h"
32-
#ifndef PLATFORM_THREAD_OVERRIDE // See details in thread.h
32+
33+
#ifndef PLATFORM_THREAD_OVERRIDE // See details in thread.h.
3334

3435
#include "thread.h"
3536

3637
#ifdef THREADS_ENABLED
3738
#include "core/object/script_language.h"
38-
#include "core/templates/safe_refcount.h"
3939

4040
SafeNumeric<uint64_t> Thread::id_counter(1); // The first value after .increment() is 2, hence by default the main thread ID should be 1.
4141

core/os/thread.h

+14-5
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,28 @@
2929
/**************************************************************************/
3030

3131
#include "platform_config.h"
32+
3233
// Define PLATFORM_THREAD_OVERRIDE in your platform's `platform_config.h`
33-
// to use a custom Thread implementation defined in `platform/[your_platform]/platform_thread.h`
34-
// Overriding the platform implementation is required in some proprietary platforms
34+
// to use a custom Thread implementation defined in `platform/[your_platform]/platform_thread.h`.
35+
// Overriding the Thread implementation is required in some proprietary platforms.
36+
3537
#ifdef PLATFORM_THREAD_OVERRIDE
38+
3639
#include "platform_thread.h"
40+
3741
#else
3842

3943
#ifndef THREAD_H
4044
#define THREAD_H
4145

42-
#include "core/templates/safe_refcount.h"
4346
#include "core/typedefs.h"
4447

48+
#ifdef THREADS_ENABLED
49+
50+
#include "core/templates/safe_refcount.h"
51+
52+
#include <new> // IWYU pragma: keep // For hardware interference size.
53+
4554
#ifdef MINGW_ENABLED
4655
#define MINGW_STDTHREAD_REDUNDANCY_WARNING
4756
#include "thirdparty/mingw-std-threads/mingw.thread.h"
@@ -53,8 +62,6 @@
5362

5463
class String;
5564

56-
#ifdef THREADS_ENABLED
57-
5865
class Thread {
5966
public:
6067
typedef void (*Callback)(void *p_userdata);
@@ -143,6 +150,8 @@ class Thread {
143150

144151
#else // No threads.
145152

153+
class String;
154+
146155
class Thread {
147156
public:
148157
typedef void (*Callback)(void *p_userdata);

core/os/thread_safe.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#ifndef THREAD_SAFE_H
3232
#define THREAD_SAFE_H
3333

34+
#include "core/os/mutex.h" // IWYU pragma: keep // Used in macro.
35+
3436
#define _THREAD_SAFE_CLASS_ mutable Mutex _thread_safe_;
3537
#define _THREAD_SAFE_METHOD_ MutexLock _thread_safe_method_(_thread_safe_);
3638
#define _THREAD_SAFE_LOCK_ _thread_safe_.lock();

0 commit comments

Comments
 (0)