Remove Superfluous Mutexes

This commit is contained in:
TheBrokenRail 2022-07-13 19:32:08 -04:00
parent c87a6fa3c0
commit 9fe6a2fb39
5 changed files with 5 additions and 16 deletions

View File

@ -37,5 +37,5 @@ TRUE Improved Title Background
TRUE Force Touch GUI Button Behavior TRUE Force Touch GUI Button Behavior
TRUE Improved Button Hover Behavior TRUE Improved Button Hover Behavior
TRUE Implement Create World Dialog TRUE Implement Create World Dialog
FALSE Remove Forced GUI Lag (Cam Break Server Joining) FALSE Remove Forced GUI Lag (Can Break Joining Servers)
TRUE Add Buckets TRUE Add Buckets

View File

@ -23,7 +23,7 @@ if(BUILD_ARM_COMPONENTS)
endif() endif()
# Link # Link
target_link_libraries(media-layer-core PUBLIC media-layer-headers PUBLIC reborn-util PUBLIC GLESv1_CM PUBLIC pthread PUBLIC dl) target_link_libraries(media-layer-core PUBLIC media-layer-headers PUBLIC reborn-util PUBLIC GLESv1_CM PUBLIC dl)
if(NOT MCPI_HEADLESS_MODE) if(NOT MCPI_HEADLESS_MODE)
# OpenAL # OpenAL
find_library(OPENAL_LIBRARY NAMES openal REQUIRED) find_library(OPENAL_LIBRARY NAMES openal REQUIRED)

View File

@ -1,5 +1,4 @@
#include <cstdlib> #include <cstdlib>
#include <pthread.h>
#include <vector> #include <vector>
#include <SDL/SDL.h> #include <SDL/SDL.h>
@ -15,7 +14,6 @@ int SDL_Init(__attribute__((unused)) uint32_t flags) {
// Event Queue // Event Queue
static pthread_mutex_t queue_mutex = PTHREAD_MUTEX_INITIALIZER;
static std::vector<SDL_Event> queue; static std::vector<SDL_Event> queue;
int SDL_PollEvent(SDL_Event *event) { int SDL_PollEvent(SDL_Event *event) {
@ -23,7 +21,6 @@ int SDL_PollEvent(SDL_Event *event) {
_media_handle_SDL_PollEvent(); _media_handle_SDL_PollEvent();
// Poll Event // Poll Event
pthread_mutex_lock(&queue_mutex);
int ret; int ret;
if (queue.size() > 0) { if (queue.size() > 0) {
*event = queue[0]; *event = queue[0];
@ -32,14 +29,11 @@ int SDL_PollEvent(SDL_Event *event) {
} else { } else {
ret = 0; ret = 0;
} }
pthread_mutex_unlock(&queue_mutex);
return ret; return ret;
} }
int SDL_PushEvent(SDL_Event *event) { int SDL_PushEvent(SDL_Event *event) {
pthread_mutex_lock(&queue_mutex);
queue.push_back(*event); queue.push_back(*event);
pthread_mutex_unlock(&queue_mutex);
return 1; return 1;
} }

View File

@ -1,7 +1,6 @@
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
#include <unistd.h> #include <unistd.h>
#include <pthread.h>
#include <csignal> #include <csignal>
#include <sys/wait.h> #include <sys/wait.h>
#include <fcntl.h> #include <fcntl.h>
@ -156,16 +155,12 @@ unsigned char _get_unique_id(const char *name) {
return get_unique_ids()[name]; // Assume ID Exists return get_unique_ids()[name]; // Assume ID Exists
} }
// The Proxy Is Single-Threaded // Proxy Call Functions
static pthread_mutex_t proxy_mutex = PTHREAD_MUTEX_INITIALIZER;
void _start_proxy_call(unsigned char call_id) { void _start_proxy_call(unsigned char call_id) {
// Lock Proxy // Start Call
pthread_mutex_lock(&proxy_mutex);
write_byte(call_id); write_byte(call_id);
} }
void end_proxy_call() { void end_proxy_call() {
// Flush Write Cache // Flush Write Cache
flush_write_cache(); flush_write_cache();
// Release Proxy
pthread_mutex_unlock(&proxy_mutex);
} }

View File

@ -275,7 +275,7 @@ void init_misc() {
} }
// Remove Forced GUI Lag // Remove Forced GUI Lag
if (feature_has("Remove Forced GUI Lag (Cam Break Server Joining)", server_enabled)) { if (feature_has("Remove Forced GUI Lag (Can Break Joining Servers)", server_enabled)) {
overwrite_calls((void *) sleepMs, (void *) nop); overwrite_calls((void *) sleepMs, (void *) nop);
} }