mirror of
https://github.com/flightlessmango/MangoHud.git
synced 2024-11-04 06:00:23 +00:00
[config] keep pthread_t pointers in notify_thread struct for MT safety
This commit is contained in:
parent
1b192c4910
commit
d3f895cbef
@ -1,4 +1,3 @@
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@ -7,8 +6,6 @@
|
||||
#include "config.h"
|
||||
#include "notify.h"
|
||||
|
||||
pthread_t fileChange;
|
||||
|
||||
#define EVENT_SIZE ( sizeof (struct inotify_event) )
|
||||
#define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
|
||||
|
||||
@ -50,7 +47,7 @@ bool start_notifier(notify_thread& nt)
|
||||
return false;
|
||||
}
|
||||
|
||||
pthread_create(&fileChange, NULL, &fileChanged, &nt);
|
||||
pthread_create(&nt.thread, NULL, &fileChanged, &nt);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -65,5 +62,5 @@ void stop_notifier(notify_thread& nt)
|
||||
close(nt.fd);
|
||||
nt.fd = -1;
|
||||
|
||||
pthread_join(fileChange, nullptr);
|
||||
pthread_join(nt.thread, nullptr);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include "overlay_params.h"
|
||||
|
||||
@ -7,6 +8,7 @@ struct notify_thread
|
||||
overlay_params *params = nullptr;
|
||||
bool quit = false;
|
||||
std::mutex mutex;
|
||||
pthread_t thread;
|
||||
};
|
||||
|
||||
bool start_notifier(notify_thread& nt);
|
||||
|
Loading…
Reference in New Issue
Block a user