UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AndroidPlatformRunnableThread.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================================
4 AndroidPlatformRunnableThread.h: Android platform threading functions
5==============================================================================================*/
6
7#pragma once
8
11#include "AndroidPlatform.h"
12
16class FRunnableThreadAndroid : public FRunnableThreadPThread
17{
18 enum
19 {
20 AndroidThreadNameLimit = 15 // android name limit is 16, but we'll go with 15 to be safe and match the linux implementation
21 };
22
23public:
24 FRunnableThreadAndroid() : FRunnableThreadPThread()
25 {
26 }
27
29 {
30 // Call the parent destructor body before the parent does it - see comment on that function for explanation why.
32 }
33
34private:
35
39 virtual void PreRun()
40 {
41 FString SizeLimitedThreadName = ThreadName;
42
43 if (SizeLimitedThreadName.Len() > AndroidThreadNameLimit)
44 {
45 // first, attempt to cut out common and meaningless substrings
46 SizeLimitedThreadName = SizeLimitedThreadName.Replace(TEXT("Thread"), TEXT(""));
47 SizeLimitedThreadName = SizeLimitedThreadName.Replace(TEXT("Runnable"), TEXT(""));
48
49 // if still larger
50 if (SizeLimitedThreadName.Len() > AndroidThreadNameLimit)
51 {
52 FString Temp = SizeLimitedThreadName;
53
54 // cut out the middle and replace with a substitute
55 const TCHAR Dash[] = TEXT("-");
56 const int32 DashLen = UE_ARRAY_COUNT(Dash) - 1;
57 int NumToLeave = (AndroidThreadNameLimit - DashLen) / 2;
58
59 SizeLimitedThreadName = Temp.Left(AndroidThreadNameLimit - (NumToLeave + DashLen));
61 SizeLimitedThreadName += Temp.Right(NumToLeave);
62
63 check(SizeLimitedThreadName.Len() <= AndroidThreadNameLimit);
64 }
65 }
66
68 }
69
73 virtual uint32 AdjustStackSize(uint32 InStackSize)
74 {
75 InStackSize = FRunnableThreadPThread::AdjustStackSize(InStackSize);
76
77 // If it's set, make sure it's at least 128 KB or stack allocations (e.g. in Logf) may fail
78 if (InStackSize && InStackSize < 128 * 1024)
79 {
80 InStackSize = 128 * 1024;
81 }
82
83 return InStackSize;
84 }
85
86#if ANDROID_USE_NICE_VALUE_THREADPRIORITY
89#endif
90};
#define check(expr)
Definition AssertionMacros.h:314
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EThreadPriority
Definition GenericPlatformAffinity.h:26
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AndroidPlatformRunnableThread.h:17
~FRunnableThreadAndroid()
Definition AndroidPlatformRunnableThread.h:28
FRunnableThreadAndroid()
Definition AndroidPlatformRunnableThread.h:24
Type SetThreadPriority(Type ThreadAndIndex, Type ThreadPriority)
Definition TaskGraphInterfaces.h:190
static CORE_API void SetThreadName(const TCHAR *ThreadName)
Definition AndroidPlatformProcess.cpp:173