N64ModernRuntime/ultramodern/include/ultramodern/threads.hpp
Anghelo Carvajal 27282afa2b
Remove "permanent" and "temporary" threads tagging and add a way to name game threads (#45)
* System to specify thread types by the game

* Register threads callbacks

* Remove temporary and permanent threads

* Fix `pthread_setname_np` not liking names longer than 16 bytes

* Singular

* Rename events_callbacks arg

* Use `prctl` instead of `pthread_setname_np` for naming a thread

* Fix typo
2024-06-18 13:02:18 -04:00

29 lines
864 B
C++

#ifndef __THREADS_HPP__
#define __THREADS_HPP__
#include <string>
#include "ultra64.h"
namespace ultramodern {
namespace threads {
struct callbacks_t {
using get_game_thread_name_t = std::string(const OSThread* t);
/**
* Allows to specifying a custom name for each thread. Mainly for debugging purposes.
*
* For maximum cross-platform compatibility the returned name should be at most 15 bytes long (16 bytes including the null terminator).
*
* If this function is not provided then the thread id will be used as the name of the thread.
*/
get_game_thread_name_t *get_game_thread_name;
};
void set_callbacks(const callbacks_t& callbacks);
std::string get_game_thread_name(const OSThread* t);
}
}
#endif