mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
noexcept usage fixed
thread_t renamed to named_thread_t
This commit is contained in:
parent
168cd9bb7a
commit
5e14310071
26 changed files with 82 additions and 96 deletions
|
|
@ -64,7 +64,7 @@ namespace fs
|
|||
|
||||
struct file final
|
||||
{
|
||||
using handle_type = intptr_t;
|
||||
using handle_type = std::intptr_t;
|
||||
|
||||
static const handle_type null = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
#include <emmintrin.h>
|
||||
|
||||
// temporarily (until noexcept is available); use `noexcept(true)` instead of `noexcept` if necessary
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
||||
#define noexcept _NOEXCEPT_OP
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
||||
#define thread_local __declspec(thread)
|
||||
#elif __APPLE__
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ sleep_queue_entry_t::sleep_queue_entry_t(CPUThread& cpu, sleep_queue_t& queue, c
|
|||
cpu.sleep();
|
||||
}
|
||||
|
||||
sleep_queue_entry_t::~sleep_queue_entry_t() noexcept(false)
|
||||
sleep_queue_entry_t::~sleep_queue_entry_t()
|
||||
{
|
||||
remove_entry();
|
||||
m_thread.awake();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public:
|
|||
sleep_queue_entry_t(CPUThread& cpu, sleep_queue_t& queue, const defer_sleep_t&);
|
||||
|
||||
// removes specified thread from the sleep queue if added
|
||||
~sleep_queue_entry_t() noexcept(false);
|
||||
~sleep_queue_entry_t();
|
||||
|
||||
// add thread to the sleep queue
|
||||
inline void enter()
|
||||
|
|
|
|||
|
|
@ -1199,20 +1199,21 @@ std::string thread_ctrl_t::get_name() const
|
|||
return name();
|
||||
}
|
||||
|
||||
thread_t::thread_t(std::function<std::string()> name, std::function<void()> func)
|
||||
named_thread_t::named_thread_t(std::function<std::string()> name, std::function<void()> func)
|
||||
{
|
||||
start(std::move(name), func);
|
||||
}
|
||||
|
||||
thread_t::~thread_t() //noexcept(false)
|
||||
named_thread_t::~named_thread_t()
|
||||
{
|
||||
if (m_thread)
|
||||
{
|
||||
throw EXCEPTION("Neither joined nor detached");
|
||||
std::printf("Fatal: thread '%s' is neither joined nor detached\n", this->get_name().c_str());
|
||||
std::terminate();
|
||||
}
|
||||
}
|
||||
|
||||
std::string thread_t::get_name() const
|
||||
std::string named_thread_t::get_name() const
|
||||
{
|
||||
if (!m_thread)
|
||||
{
|
||||
|
|
@ -1229,7 +1230,7 @@ std::string thread_t::get_name() const
|
|||
|
||||
std::atomic<u32> g_thread_count{ 0 };
|
||||
|
||||
void thread_t::start(std::function<std::string()> name, std::function<void()> func)
|
||||
void named_thread_t::start(std::function<std::string()> name, std::function<void()> func)
|
||||
{
|
||||
if (m_thread)
|
||||
{
|
||||
|
|
@ -1302,7 +1303,7 @@ void thread_t::start(std::function<std::string()> name, std::function<void()> fu
|
|||
}, m_thread, std::move(func));
|
||||
}
|
||||
|
||||
void thread_t::detach()
|
||||
void named_thread_t::detach()
|
||||
{
|
||||
if (!m_thread)
|
||||
{
|
||||
|
|
@ -1324,7 +1325,7 @@ void thread_t::detach()
|
|||
ctrl->m_thread.detach();
|
||||
}
|
||||
|
||||
void thread_t::join()
|
||||
void named_thread_t::join()
|
||||
{
|
||||
if (!m_thread)
|
||||
{
|
||||
|
|
@ -1349,7 +1350,7 @@ void thread_t::join()
|
|||
ctrl->m_thread.join();
|
||||
}
|
||||
|
||||
bool thread_t::is_current() const
|
||||
bool named_thread_t::is_current() const
|
||||
{
|
||||
if (!m_thread)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const class thread_ctrl_t* get_current_thread_ctrl();
|
|||
// named thread control class
|
||||
class thread_ctrl_t final
|
||||
{
|
||||
friend class thread_t;
|
||||
friend class named_thread_t;
|
||||
|
||||
// thread handler
|
||||
std::thread m_thread;
|
||||
|
|
@ -23,7 +23,7 @@ public:
|
|||
std::string get_name() const;
|
||||
};
|
||||
|
||||
class thread_t
|
||||
class named_thread_t
|
||||
{
|
||||
// pointer to managed resource (shared with actual thread)
|
||||
std::shared_ptr<thread_ctrl_t> m_thread;
|
||||
|
|
@ -37,17 +37,17 @@ public:
|
|||
|
||||
public:
|
||||
// initialize in empty state
|
||||
thread_t() = default;
|
||||
named_thread_t() = default;
|
||||
|
||||
// create named thread
|
||||
thread_t(std::function<std::string()> name, std::function<void()> func);
|
||||
named_thread_t(std::function<std::string()> name, std::function<void()> func);
|
||||
|
||||
// destructor, joins automatically (questionable, don't rely on this functionality in derived destructors)
|
||||
virtual ~thread_t() /*noexcept(false) compile error on osx*/;
|
||||
// destructor, will terminate if thread is neither joined nor detached
|
||||
virtual ~named_thread_t();
|
||||
|
||||
thread_t(const thread_t&) = delete;
|
||||
named_thread_t(const named_thread_t&) = delete;
|
||||
|
||||
thread_t& operator =(const thread_t&) = delete;
|
||||
named_thread_t& operator =(const named_thread_t&) = delete;
|
||||
|
||||
public:
|
||||
// get thread name
|
||||
|
|
@ -72,11 +72,11 @@ public:
|
|||
const thread_ctrl_t* get_thread_ctrl() const { return m_thread.get(); }
|
||||
};
|
||||
|
||||
class autojoin_thread_t final : private thread_t
|
||||
class autojoin_thread_t final : private named_thread_t
|
||||
{
|
||||
public:
|
||||
using thread_t::mutex;
|
||||
using thread_t::cv;
|
||||
using named_thread_t::mutex;
|
||||
using named_thread_t::cv;
|
||||
|
||||
public:
|
||||
autojoin_thread_t() = delete;
|
||||
|
|
@ -91,7 +91,7 @@ public:
|
|||
join();
|
||||
}
|
||||
|
||||
using thread_t::is_current;
|
||||
using named_thread_t::is_current;
|
||||
};
|
||||
|
||||
extern const std::function<bool()> SQUEUE_ALWAYS_EXIT;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue