Skip to content

Commit

Permalink
make number of threads for multithreaded operations a preference
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Oct 5, 2018
1 parent 1b6ea1a commit 0738389
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/PrefsManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "Foreach.h"
#include "IniFile.h"
#include "LuaManager.h"
Expand Down Expand Up @@ -228,9 +228,9 @@ PrefsManager::PrefsManager()
, m_sTestInitialScreen("TestInitialScreen", "")
, m_MuteActions("MuteActions", false)
, m_bAllowSongDeletion("AllowSongDeletion", false)
,
, ThreadsToUse("ThreadsToUse", 0)

m_bQuirksMode("QuirksMode", false)
, m_bQuirksMode("QuirksMode", false)
,

/* Debug: */
Expand Down
3 changes: 2 additions & 1 deletion src/PrefsManager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef PREFSMANAGER_H
#ifndef PREFSMANAGER_H
#define PREFSMANAGER_H

#include "GameConstantsAndTypes.h"
Expand Down Expand Up @@ -248,6 +248,7 @@ class PrefsManager
Preference<bool> m_bAllowSongDeletion; // Allow the user to remove songs
// from their collection through UI /
// keyboard shortcut
Preference<int> ThreadsToUse;

/** @brief Enable some quirky behavior used by some older versions of
* StepMania. */
Expand Down
4 changes: 3 additions & 1 deletion src/RageThreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ parallelExecution(vector<T> vec,
function<void(vectorRange<T>, ThreadData*)> exec,
void* stuff)
{
const int THREADS = std::thread::hardware_concurrency();
const int THREADS = PREFSMAN->ThreadsToUse <= 0
? std::thread::hardware_concurrency()
: min((int)PREFSMAN->ThreadsToUse, (int)std::thread::hardware_concurrency());
std::vector<vectorRange<T>> workloads =
splitWorkLoad(vec, static_cast<size_t>(vec.size() / THREADS));
ThreadData data;
Expand Down

0 comments on commit 0738389

Please sign in to comment.