Add option for experimental use of thread in Web

Might not run well in certain browsers, requires rebuilding all dependencies for Web with `pthread` enabled.
Disabled by default (for now).
This commit is contained in:
Wojtek Figat
2026-03-14 22:11:36 +01:00
parent 21b2e59fbb
commit a5bbf0dbde
6 changed files with 36 additions and 0 deletions

View File

@@ -54,23 +54,39 @@ public:
}
FORCE_INLINE static int32 AtomicRead(int32 const volatile* dst)
{
#ifdef __EMSCRIPTEN_PTHREADS__
int32 result;
__atomic_load(dst, &result, __ATOMIC_SEQ_CST);
return result;
#else
return *dst;
#endif
}
FORCE_INLINE static int64 AtomicRead(int64 const volatile* dst)
{
#ifdef __EMSCRIPTEN_PTHREADS__
int64 result;
__atomic_load(dst, &result, __ATOMIC_SEQ_CST);
return result;
#else
return *dst;
#endif
}
FORCE_INLINE static void AtomicStore(int32 volatile* dst, int32 value)
{
#ifdef __EMSCRIPTEN_PTHREADS__
__atomic_store(dst, &value, __ATOMIC_SEQ_CST);
#else
*dst = value;
#endif
}
FORCE_INLINE static void AtomicStore(int64 volatile* dst, int64 value)
{
#ifdef __EMSCRIPTEN_PTHREADS__
__atomic_store(dst, &value, __ATOMIC_SEQ_CST);
#else
*dst = value;
#endif
}
FORCE_INLINE static uint64 GetCurrentThreadID()
{