summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-04-07 06:13:12 -0400
committerShadowNinja <shadowninja@minetest.net>2015-08-23 22:04:06 -0400
commite4bff8be94c0db4f94e63ad448d0eeb869ccdbbd (patch)
tree7935586e79da5c8c7144e345a8c0fc1cda53beed /src/settings.cpp
parent6a1047d8c116f793890b63427d53f04ceca95d54 (diff)
downloadminetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.tar.gz
minetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.tar.bz2
minetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.zip
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<type>`. * 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.
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index e95bd436d..3d4d56fa3 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "irrlichttypes_bloated.h"
#include "exceptions.h"
-#include "jthread/jmutexautolock.h"
+#include "threading/mutex_auto_lock.h"
#include "strfnd.h"
#include <iostream>
#include <fstream>
@@ -56,8 +56,8 @@ Settings & Settings::operator = (const Settings &other)
if (&other == this)
return *this;
- JMutexAutoLock lock(m_mutex);
- JMutexAutoLock lock2(other.m_mutex);
+ MutexAutoLock lock(m_mutex);
+ MutexAutoLock lock2(other.m_mutex);
clearNoLock();
updateNoLock(other);
@@ -155,7 +155,7 @@ bool Settings::readConfigFile(const char *filename)
bool Settings::parseConfigLines(std::istream &is, const std::string &end)
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
std::string line, name, value;
@@ -194,7 +194,7 @@ bool Settings::parseConfigLines(std::istream &is, const std::string &end)
void Settings::writeLines(std::ostream &os, u32 tab_depth) const
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
for (std::map<std::string, SettingsEntry>::const_iterator
it = m_settings.begin();
@@ -298,7 +298,7 @@ bool Settings::updateConfigObject(std::istream &is, std::ostream &os,
bool Settings::updateConfigFile(const char *filename)
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
std::ifstream is(filename);
std::ostringstream os(std::ios_base::binary);
@@ -379,7 +379,7 @@ bool Settings::parseCommandLine(int argc, char *argv[],
const SettingsEntry &Settings::getEntry(const std::string &name) const
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
std::map<std::string, SettingsEntry>::const_iterator n;
if ((n = m_settings.find(name)) == m_settings.end()) {
@@ -562,7 +562,7 @@ bool Settings::getNoiseParamsFromGroup(const std::string &name,
bool Settings::exists(const std::string &name) const
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
return (m_settings.find(name) != m_settings.end() ||
m_defaults.find(name) != m_defaults.end());
@@ -742,7 +742,7 @@ bool Settings::setEntry(const std::string &name, const void *data,
return false;
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
SettingsEntry &entry = set_default ? m_defaults[name] : m_settings[name];
old_group = entry.group;
@@ -878,7 +878,7 @@ bool Settings::setNoiseParams(const std::string &name,
bool Settings::remove(const std::string &name)
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
delete m_settings[name].group;
return m_settings.erase(name);
@@ -887,13 +887,13 @@ bool Settings::remove(const std::string &name)
void Settings::clear()
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
clearNoLock();
}
void Settings::clearDefaults()
{
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
clearDefaultsNoLock();
}
@@ -902,7 +902,7 @@ void Settings::updateValue(const Settings &other, const std::string &name)
if (&other == this)
return;
- JMutexAutoLock lock(m_mutex);
+ MutexAutoLock lock(m_mutex);
try {
std::string val = other.get(name);
@@ -918,8 +918,8 @@ void Settings::update(const Settings &other)
if (&other == this)
return;
- JMutexAutoLock lock(m_mutex);
- JMutexAutoLock lock2(other.m_mutex);
+ MutexAutoLock lock(m_mutex);
+ MutexAutoLock lock2(other.m_mutex);
updateNoLock(other);
}
@@ -982,13 +982,13 @@ void Settings::clearDefaultsNoLock()
void Settings::registerChangedCallback(std::string name,
setting_changed_callback cbf, void *userdata)
{
- JMutexAutoLock lock(m_callbackMutex);
+ MutexAutoLock lock(m_callbackMutex);
m_callbacks[name].push_back(std::make_pair(cbf, userdata));
}
void Settings::deregisterChangedCallback(std::string name, setting_changed_callback cbf, void *userdata)
{
- JMutexAutoLock lock(m_callbackMutex);
+ MutexAutoLock lock(m_callbackMutex);
std::map<std::string, std::vector<std::pair<setting_changed_callback, void*> > >::iterator iterToVector = m_callbacks.find(name);
if (iterToVector != m_callbacks.end())
{
@@ -1004,7 +1004,7 @@ void Settings::deregisterChangedCallback(std::string name, setting_changed_callb
void Settings::doCallbacks(const std::string name)
{
- JMutexAutoLock lock(m_callbackMutex);
+ MutexAutoLock lock(m_callbackMutex);
std::map<std::string, std::vector<std::pair<setting_changed_callback, void*> > >::iterator iterToVector = m_callbacks.find(name);
if (iterToVector != m_callbacks.end())
{