Skip to content

Commit 37a56f3

Browse files
author
Roberto De Ioris
committed
conditionally compile multithreading
1 parent 33f33b0 commit 37a56f3

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎Source/UnrealEnginePython/Private/UnrealEnginePython.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ void unreal_engine_init_py_module();
99

1010

1111
void FUnrealEnginePythonModule::PythonGILRelease() {
12+
#if UEPY_THREADING
1213
ue_python_gil = PyEval_SaveThread();
14+
#endif
1315
}
1416

1517
void FUnrealEnginePythonModule::PythonGILAcquire() {
18+
#if UEPY_THREADING
1619
PyEval_RestoreThread((PyThreadState *)ue_python_gil);
20+
#endif
1721
}
1822

1923
void FUnrealEnginePythonModule::StartupModule()

‎Source/UnrealEnginePython/Private/UnrealEnginePythonPrivatePCH.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
22

33
//#define UEPY_MEMORY_DEBUG 1
4+
//#define UEPY_THREADING 1
45

56
#include "UnrealEnginePython.h"
67

‎Source/UnrealEnginePython/Public/UnrealEnginePython.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ class UNREALENGINEPYTHON_API FUnrealEnginePythonModule : public IModuleInterface
2424
struct FScopePythonGIL {
2525
FScopePythonGIL()
2626
{
27+
#if UEPY_THREADING
2728
UnrealEnginePythonModule = FModuleManager::LoadModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython");
2829
UnrealEnginePythonModule.PythonGILAcquire();
30+
#endif
2931
}
3032

3133
~FScopePythonGIL()
3234
{
35+
#if UEPY_THREADING
3336
UnrealEnginePythonModule.PythonGILRelease();
37+
#endif
3438
}
3539

3640
FUnrealEnginePythonModule UnrealEnginePythonModule;

0 commit comments

Comments
 (0)