Files
FEX-Emu--FEX/FEXCore/include/FEXCore/Utils/Threads.h
T
Ryan Houdek d1b5dfd4b1 Threads: Setup the stack tracker to not need global initialization
Also removes the atexit handler installation
This now gets tracked by an object owned by FEXLoader (and shared with
the pthreads interface)
2024-07-12 03:00:20 -07:00

51 lines
1.1 KiB
C++

// SPDX-License-Identifier: MIT
#pragma once
#include <FEXCore/fextl/memory.h>
namespace FEXCore::Threads {
using ThreadFunc = void* (*)(void* user_ptr);
class Thread;
using CreateThreadFunc = fextl::unique_ptr<Thread> (*)(ThreadFunc Func, void* Arg);
using CleanupAfterForkFunc = void (*)();
struct Pointers {
CreateThreadFunc CreateThread;
CleanupAfterForkFunc CleanupAfterFork;
};
// API
class Thread {
public:
virtual ~Thread() = default;
virtual bool joinable() = 0;
virtual bool join(void** ret) = 0;
virtual bool detach() = 0;
virtual bool IsSelf() = 0;
/**
* @name Calls provided API functions
* @{ */
static fextl::unique_ptr<Thread> Create(ThreadFunc Func, void* Arg);
static void CleanupAfterFork();
/** @} */
// Set API functions
static void SetInternalPointers(const Pointers& _Ptrs);
};
/**
* @brief Sets the calling thread's signal mask to the one provided
*
* @param Mask The new 64-bit signal mask to set
*
* @return The previous signal mask
*/
uint64_t SetSignalMask(uint64_t Mask);
void SetThreadName(const char* name);
} // namespace FEXCore::Threads