From e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Tue, 7 Apr 2015 06:13:12 -0400 Subject: Clean up threading * Rename everything. * Strip J prefix. * Change UpperCamelCase functions to lowerCamelCase. * Remove global (!) semaphore count mutex on OSX. * Remove semaphore count getter (unused, unsafe, depended on internal API functions on Windows, and used a hack on OSX). * Add `Atomic`. * Make `Thread` handle thread names. * Add support for C++11 multi-threading. * Combine pthread and win32 sources. * Remove `ThreadStarted` (unused, unneeded). * Move some includes from the headers to the sources. * Move all of `Event` into its header (allows inlining with no new includes). * Make `Event` use `Semaphore` (except on Windows). * Move some porting functions into `Thread`. * Integrate logging with `Thread`. * Add threading test. --- src/log.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/log.cpp') diff --git a/src/log.cpp b/src/log.cpp index e6d80db34..9dc574d01 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include "threads.h" -#include "jthread/jmutexautolock.h" +#include "threading/mutex_auto_lock.h" #include "debug.h" #include "gettime.h" #include "porting.h" @@ -54,8 +54,8 @@ unsigned int android_log_level_mapping[] = { #endif std::vector log_outputs[LMT_NUM_VALUES]; -std::map log_threadnames; -JMutex log_threadnamemutex; +std::map log_thread_names; +Mutex log_thread_name_mutex; void log_add_output(ILogOutput *out, enum LogMessageLevel lev) { @@ -86,7 +86,7 @@ void log_remove_output(ILogOutput *out) void log_set_lev_silence(enum LogMessageLevel lev, bool silence) { - JMutexAutoLock lock(log_threadnamemutex); + MutexAutoLock lock(log_thread_name_mutex); for (std::vector::iterator it = log_outputs[lev].begin(); it != log_outputs[lev].end(); ++it) { @@ -98,17 +98,17 @@ void log_set_lev_silence(enum LogMessageLevel lev, bool silence) void log_register_thread(const std::string &name) { threadid_t id = get_current_thread_id(); - JMutexAutoLock lock(log_threadnamemutex); + MutexAutoLock lock(log_thread_name_mutex); - log_threadnames[id] = name; + log_thread_names[id] = name; } void log_deregister_thread() { threadid_t id = get_current_thread_id(); - JMutexAutoLock lock(log_threadnamemutex); + MutexAutoLock lock(log_thread_name_mutex); - log_threadnames.erase(id); + log_thread_names.erase(id); } static std::string get_lev_string(enum LogMessageLevel lev) @@ -130,11 +130,11 @@ static std::string get_lev_string(enum LogMessageLevel lev) void log_printline(enum LogMessageLevel lev, const std::string &text) { - JMutexAutoLock lock(log_threadnamemutex); + MutexAutoLock lock(log_thread_name_mutex); std::string threadname = "(unknown thread)"; std::map::const_iterator i; - i = log_threadnames.find(get_current_thread_id()); - if(i != log_threadnames.end()) + i = log_thread_names.find(get_current_thread_id()); + if(i != log_thread_names.end()) threadname = i->second; std::string levelname = get_lev_string(lev); std::ostringstream os(std::ios_base::binary); -- cgit v1.2.3