wip: name os threads

This commit is contained in:
2026-02-24 17:49:00 +01:00
parent 5f3adf0925
commit 4f74bdc86a
3 changed files with 15 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#include <condition_variable>
#include <cstddef>
#include <mutex>
#include <pthread.h>
#include <queue>
#include <raylib.h>
#include <raymath.h>
@ -16,6 +17,7 @@
#include "octree.hpp"
#ifndef WEB
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
#include <BS_thread_pool.hpp>
#endif
@ -67,7 +69,8 @@ public:
std::vector<Spring> springs;
public:
MassSpringSystem() : threads(std::thread::hardware_concurrency() - 1) {
MassSpringSystem()
: threads(std::thread::hardware_concurrency() - 1, SetThreadName) {
std::cout << "Using Barnes-Hut + octree repulsion force calculation."
<< std::endl;
@ -83,6 +86,8 @@ public:
MassSpringSystem &operator=(MassSpringSystem &&move) = delete;
private:
static auto SetThreadName(std::size_t idx) -> void;
auto BuildOctree() -> void;
public:
@ -134,7 +139,9 @@ public:
PhysicsState state;
public:
ThreadedPhysics() : physics(PhysicsThread, std::ref(state)) {}
ThreadedPhysics() : physics(PhysicsThread, std::ref(state)) {
pthread_setname_np(physics.native_handle(), "physics");
}
ThreadedPhysics(const ThreadedPhysics &copy) = delete;
ThreadedPhysics &operator=(const ThreadedPhysics &copy) = delete;