Are there any cross-platform implementations of synchronization primitives in C++?

All I’ve been able to find are FSemaphores defined in FGenericPlatformProcess and it seems like there’s only a platform implementation for Windows. I’m hoping to find some implementations of mutexes and semaphores that at least exist for Mac/PC/Linux and Android.

Thanks!

Hmm maybe post feature request on feedback forum, or if you up to it write implementations to other platfroms and submit pull request

Bumb. Yeah. It’s kinda frustrating that a multi platform engine would implement something like this for only a single platform.

Well without common implementation in UE4 you are forced to learn and use platfrom specific either way

There actually is, it’s called FEvent and represents a simple signaling primitive. It’s used for example to ensure the game thread waits for the render thread.

There are other primitives such as FScopedEvent or FThreadSafeCounter, have a look into ThreadingBase.h.

You have even FPlatformMisc::MemoryBarrier(); supported in every platform.

Oh if I only knew how they worked on other platforms. I guess I’ll have to learn someday.

In case that someone needs an example on how to use FEvent I made a short Wiki with example: MultiThreading and synchronization Guide