Thread.h: Add a few noexcept

This commit is contained in:
Elad 2024-12-23 15:32:16 +02:00
parent 3bf735161f
commit 6a4b9430c0
2 changed files with 15 additions and 15 deletions

View File

@ -2555,13 +2555,13 @@ std::string thread_ctrl::get_name_cached()
return *name_cache;
}
thread_base::thread_base(native_entry entry, std::string name)
thread_base::thread_base(native_entry entry, std::string name) noexcept
: entry_point(entry)
, m_tname(make_single_value(std::move(name)))
{
}
thread_base::~thread_base()
thread_base::~thread_base() noexcept
{
// Cleanup abandoned tasks: initialize default results and signal
this->exec();
@ -2602,7 +2602,7 @@ bool thread_base::join(bool dtor) const
if (i >= 16 && !(i & (i - 1)) && timeout != atomic_wait_timeout::inf)
{
sig_log.error(u8"Thread [%s] is too sleepy. Waiting for it %.3fus already!", *m_tname.load(), (utils::get_tsc() - stamp0) / (utils::get_tsc_freq() / 1000000.));
sig_log.error("Thread [%s] is too sleepy. Waiting for it %.3fus already!", *m_tname.load(), (utils::get_tsc() - stamp0) / (utils::get_tsc_freq() / 1000000.));
}
}

View File

@ -172,9 +172,9 @@ private:
friend class named_thread;
protected:
thread_base(native_entry, std::string name);
thread_base(native_entry, std::string name) noexcept;
~thread_base();
~thread_base() noexcept;
public:
// Get CPU cycles since last time this function was called. First call returns 0.
@ -351,7 +351,7 @@ public:
// Sets the native thread priority and returns it to zero at destructor
struct scoped_priority
{
explicit scoped_priority(int prio)
explicit scoped_priority(int prio) noexcept
{
set_native_priority(prio);
}
@ -360,7 +360,7 @@ public:
scoped_priority& operator=(const scoped_priority&) = delete;
~scoped_priority()
~scoped_priority() noexcept
{
set_native_priority(0);
}
@ -388,7 +388,7 @@ class thread_future_t : public thread_future, result_storage<Ctx, std::condition
using future = thread_future_t;
public:
thread_future_t(Ctx&& func, Args&&... args)
thread_future_t(Ctx&& func, Args&&... args) noexcept
: m_args(std::forward<Args>(args)...)
, m_func(std::forward<Ctx>(func))
{
@ -417,7 +417,7 @@ public:
};
}
~thread_future_t()
~thread_future_t() noexcept
{
if constexpr (!future::empty && !Discard)
{
@ -570,7 +570,7 @@ public:
named_thread& operator=(const named_thread&) = delete;
// Wait for the completion and access result (if not void)
[[nodiscard]] decltype(auto) operator()()
[[nodiscard]] decltype(auto) operator()() noexcept
{
thread::join();
@ -581,7 +581,7 @@ public:
}
// Wait for the completion and access result (if not void)
[[nodiscard]] decltype(auto) operator()() const
[[nodiscard]] decltype(auto) operator()() const noexcept
{
thread::join();
@ -593,7 +593,7 @@ public:
// Send command to the thread to invoke directly (references should be passed via std::ref())
template <bool Discard = true, typename Arg, typename... Args>
auto operator()(Arg&& arg, Args&&... args)
auto operator()(Arg&& arg, Args&&... args) noexcept
{
// Overloaded operator() of the Context.
constexpr bool v1 = std::is_invocable_v<Context, Arg&&, Args&&...>;
@ -667,12 +667,12 @@ public:
}
// Access thread state
operator thread_state() const
operator thread_state() const noexcept
{
return static_cast<thread_state>(thread::m_sync.load() & 3);
}
named_thread& operator=(thread_state s)
named_thread& operator=(thread_state s) noexcept
{
if (s == thread_state::created)
{
@ -717,7 +717,7 @@ public:
}
// Context type doesn't need virtual destructor
~named_thread()
~named_thread() noexcept
{
// Assign aborting state forcefully and join thread
operator=(thread_state::finished);