wip: name os threads
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <pthread.h>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
@ -16,6 +17,7 @@
|
|||||||
#include "octree.hpp"
|
#include "octree.hpp"
|
||||||
|
|
||||||
#ifndef WEB
|
#ifndef WEB
|
||||||
|
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
||||||
#include <BS_thread_pool.hpp>
|
#include <BS_thread_pool.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -67,7 +69,8 @@ public:
|
|||||||
std::vector<Spring> springs;
|
std::vector<Spring> springs;
|
||||||
|
|
||||||
public:
|
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::cout << "Using Barnes-Hut + octree repulsion force calculation."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
@ -83,6 +86,8 @@ public:
|
|||||||
MassSpringSystem &operator=(MassSpringSystem &&move) = delete;
|
MassSpringSystem &operator=(MassSpringSystem &&move) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static auto SetThreadName(std::size_t idx) -> void;
|
||||||
|
|
||||||
auto BuildOctree() -> void;
|
auto BuildOctree() -> void;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -134,7 +139,9 @@ public:
|
|||||||
PhysicsState state;
|
PhysicsState state;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThreadedPhysics() : physics(PhysicsThread, std::ref(state)) {}
|
ThreadedPhysics() : physics(PhysicsThread, std::ref(state)) {
|
||||||
|
pthread_setname_np(physics.native_handle(), "physics");
|
||||||
|
}
|
||||||
|
|
||||||
ThreadedPhysics(const ThreadedPhysics ©) = delete;
|
ThreadedPhysics(const ThreadedPhysics ©) = delete;
|
||||||
ThreadedPhysics &operator=(const ThreadedPhysics ©) = delete;
|
ThreadedPhysics &operator=(const ThreadedPhysics ©) = delete;
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
// - Click states to display them in the board
|
// - Click states to display them in the board
|
||||||
// - Find shortest path to any winning state and mark it in the graph
|
// - Find shortest path to any winning state and mark it in the graph
|
||||||
// - Also mark the next move along the path on the board
|
// - Also mark the next move along the path on the board
|
||||||
|
// TODO: Do I have a huge memory leak or is the memory just not reclaimed from
|
||||||
|
// the C++ runtime?
|
||||||
|
|
||||||
auto main(int argc, char *argv[]) -> int {
|
auto main(int argc, char *argv[]) -> int {
|
||||||
// if (argc < 2) {
|
// if (argc < 2) {
|
||||||
|
|||||||
@ -108,6 +108,10 @@ auto MassSpringSystem::CalculateSpringForces() -> void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto MassSpringSystem::SetThreadName(std::size_t idx) -> void {
|
||||||
|
BS::this_thread::set_os_thread_name(std::format("bh-worker-{}", idx));
|
||||||
|
}
|
||||||
|
|
||||||
auto MassSpringSystem::BuildOctree() -> void {
|
auto MassSpringSystem::BuildOctree() -> void {
|
||||||
ZoneScoped;
|
ZoneScoped;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user