UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AndroidPlatformTLS.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4/*=============================================================================================
5 AndroidTLS.h: Android platform TLS (Thread local storage and thread ID) functions
6==============================================================================================*/
7
8#pragma once
11
16{
20 static inline uint32 GetCurrentThreadId(void)
21 {
22 static_assert(sizeof(pid_t) <= sizeof(uint32), "pid_t is larger than uint32, reconsider implementation of GetCurrentThreadId()");
23 return static_cast<uint32>(gettid());
24// return pthread_self();
25 }
26
30 static inline uint32 AllocTlsSlot(void)
31 {
32 // allocate a per-thread mem slot
33 pthread_key_t Key = 0;
34 if (pthread_key_create(&Key, NULL) != 0)
35 {
36 Key = InvalidTlsSlot; // matches the Windows TlsAlloc() retval //@todo android: should probably check for this below, or assert out instead
37 }
38 return Key;
39 }
40
47 static UE_FORCEINLINE_HINT void SetTlsValue(uint32 SlotIndex,void* Value)
48 {
50 }
51
57 static UE_FORCEINLINE_HINT void* GetTlsValue(uint32 SlotIndex)
58 {
59 return pthread_getspecific((pthread_key_t)SlotIndex);
60 }
61
67 static UE_FORCEINLINE_HINT void FreeTlsSlot(uint32 SlotIndex)
68 {
70 }
71};
72
#define NULL
Definition oodle2base.h:134
FAndroidTLS FPlatformTLS
Definition AndroidPlatformTLS.h:73
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AndroidPlatformTLS.h:16
static uint32 GetCurrentThreadId(void)
Definition AndroidPlatformTLS.h:20
static uint32 AllocTlsSlot(void)
Definition AndroidPlatformTLS.h:30
static UE_FORCEINLINE_HINT void FreeTlsSlot(uint32 SlotIndex)
Definition AndroidPlatformTLS.h:67
static UE_FORCEINLINE_HINT void * GetTlsValue(uint32 SlotIndex)
Definition AndroidPlatformTLS.h:57
static UE_FORCEINLINE_HINT void SetTlsValue(uint32 SlotIndex, void *Value)
Definition AndroidPlatformTLS.h:47
Definition GenericPlatformTLS.h:12
static const uint32 InvalidTlsSlot
Definition GenericPlatformTLS.h:13