diff --git a/src/Platform.c b/src/Platform.c index 8ffa38b..71beb23 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -211,11 +211,11 @@ void PltDetachThread(PLT_THREAD* thread) { } bool PltIsThreadInterrupted(PLT_THREAD* thread) { - return thread->cancelled; + return atomic_load_explicit(&thread->cancelled, memory_order_acquire); } void PltInterruptThread(PLT_THREAD* thread) { - thread->cancelled = true; + atomic_store_explicit(&thread->cancelled, true, memory_order_release); } #ifdef __WIIU__ diff --git a/src/PlatformThreads.h b/src/PlatformThreads.h index 822b90b..90db3f6 100644 --- a/src/PlatformThreads.h +++ b/src/PlatformThreads.h @@ -3,6 +3,8 @@ #include "Limelight.h" #include "Platform.h" +#include + typedef void(*ThreadEntry)(void* context); #if defined(LC_WINDOWS) @@ -10,28 +12,28 @@ typedef SRWLOCK PLT_MUTEX; typedef CONDITION_VARIABLE PLT_COND; typedef struct _PLT_THREAD { HANDLE handle; - bool cancelled; + atomic_bool cancelled; } PLT_THREAD; #elif defined(__WIIU__) typedef OSFastMutex PLT_MUTEX; typedef OSFastCondition PLT_COND; typedef struct _PLT_THREAD { OSThread thread; - int cancelled; + atomic_bool cancelled; } PLT_THREAD; #elif defined(__3DS__) typedef LightLock PLT_MUTEX; typedef CondVar PLT_COND; typedef struct _PLT_THREAD { Thread thread; - bool cancelled; + atomic_bool cancelled; } PLT_THREAD; #elif defined (LC_POSIX) typedef pthread_mutex_t PLT_MUTEX; typedef pthread_cond_t PLT_COND; typedef struct _PLT_THREAD { pthread_t thread; - bool cancelled; + atomic_bool cancelled; } PLT_THREAD; #else #error Unsupported platform