summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--game/client/main.cc4
-rw-r--r--game/server/main.cc2
-rw-r--r--game/shared/threading.cc24
3 files changed, 23 insertions, 7 deletions
diff --git a/game/client/main.cc b/game/client/main.cc
index 2fadb9f..6fabaa3 100644
--- a/game/client/main.cc
+++ b/game/client/main.cc
@@ -149,7 +149,7 @@ int main(int argc, char **argv)
shared_game::init(argc, argv);
- spdlog::info("Voxelius {}", PROJECT_VERSION_STRING);
+ spdlog::info("Voxelius Client {}", PROJECT_VERSION_STRING);
glfwSetErrorCallback(&on_glfw_error);
@@ -165,8 +165,6 @@ int main(int argc, char **argv)
std::terminate();
}
- spdlog::info("GLFW {}", glfwGetVersionString());
-
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
diff --git a/game/server/main.cc b/game/server/main.cc
index 64bca10..0eff05f 100644
--- a/game/server/main.cc
+++ b/game/server/main.cc
@@ -30,7 +30,7 @@ int main(int argc, char **argv)
shared_game::init(argc, argv);
- spdlog::info("Voxelius {} server", PROJECT_VERSION_STRING);
+ spdlog::info("Voxelius Server {}", PROJECT_VERSION_STRING);
globals::fixed_frametime = 0.0f;
globals::fixed_frametime_avg = 0.0f;
diff --git a/game/shared/threading.cc b/game/shared/threading.cc
index 06a9411..7e6f652 100644
--- a/game/shared/threading.cc
+++ b/game/shared/threading.cc
@@ -4,6 +4,8 @@
#include "core/cmdline.hh"
#include "core/constexpr.hh"
+constexpr static const char *DEFAULT_POOL_SIZE_ARG = "4";
+
static BS::light_thread_pool *thread_pool;
static std::deque<Task *> task_deque;
@@ -31,9 +33,25 @@ void Task::set_status(task_status status)
void threading::init(void)
{
- auto threads_arg = cmdline::get("threads", "4");
- auto threads_num = cxpr::clamp<unsigned long>(std::strtoul(threads_arg, nullptr, 10), 2U, 4U);
- thread_pool = new BS::light_thread_pool(threads_num);
+ auto argument = cmdline::get("threads", DEFAULT_POOL_SIZE_ARG);
+ auto num_concurrent_threads = std::thread::hardware_concurrency();
+ unsigned int thread_pool_size;
+
+ if(num_concurrent_threads && !std::strcmp(argument, "max")) {
+ // Use the maximum available number of concurrent
+ // hardware threads provided by the implementation
+ thread_pool_size = num_concurrent_threads;
+ }
+ else {
+ if(num_concurrent_threads)
+ thread_pool_size = cxpr::clamp<unsigned int>(std::strtoul(argument, nullptr, 10), 1U, num_concurrent_threads);
+ else thread_pool_size = cxpr::max<unsigned int>(std::strtoul(argument, nullptr, 10), 1U);
+ }
+
+ spdlog::info("threading: using {} threads for pooling tasks", thread_pool_size);
+
+ thread_pool = new BS::light_thread_pool(thread_pool_size);
+
task_deque.clear();
}