Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 488b7b2

Browse files
thread safety? #61
1 parent 42b6cb8 commit 488b7b2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

OFS-lib/OFS_FileLogging.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "stb_sprintf.h"
1313
#include <vector>
1414

15+
#include <atomic>
16+
1517
static OFS::AppLog OFS_MainLog;
1618

1719
SDL_RWops* OFS_FileLogger::LogFileHandle = nullptr;
@@ -21,8 +23,8 @@ struct OFS_LogThread {
2123
SDL_cond* WaitFlush = nullptr;
2224
std::vector<char> LogMsgBuffer;
2325

24-
volatile bool ShouldExit = false;
25-
volatile bool Exited = false;
26+
std::atomic<bool> ShouldExit = false;
27+
std::atomic<bool> Exited = false;
2628

2729
void Init() noexcept
2830
{

src/api/OFS_WebsocketApi.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <vector>
55
#include <memory>
66
#include <vector>
7+
#include <atomic>
78

89
#include "SDL_thread.h"
910
#include "SDL_atomic.h"
@@ -14,8 +15,9 @@
1415
struct EventSerializationContext
1516
{
1617
SDL_cond* processCond = nullptr;
17-
volatile bool shouldExit = false;
18-
volatile bool hasExited = false;
18+
19+
std::atomic<bool> shouldExit = false;
20+
std::atomic<bool> hasExited = false;
1921

2022
SDL_SpinLock eventLock = {0};
2123
std::vector<EventPointer> events;

0 commit comments

Comments
 (0)