Remove thread_ctrl::atexit

It was only a workaround for poor C++11 thread_local support
This commit is contained in:
Nekotekina 2018-09-15 14:42:14 +03:00
parent f2229a5f53
commit c5676e5649
4 changed files with 16 additions and 57 deletions

View file

@ -1654,9 +1654,8 @@ void thread_ctrl::initialize()
void thread_ctrl::finalize(std::exception_ptr eptr) noexcept
{
// Run atexit functions
m_task.invoke();
m_task.reset();
// Report pending errors
error_code::error_report(0, 0, 0, 0);
#ifdef _WIN32
ULONG64 cycles{};
@ -1695,11 +1694,6 @@ void thread_ctrl::finalize(std::exception_ptr eptr) noexcept
m_jcv.notify_all();
}
void thread_ctrl::_push(task_stack task)
{
g_tls_this_thread->m_task.push(std::move(task));
}
bool thread_ctrl::_wait_for(u64 usec)
{
auto _this = g_tls_this_thread;

View file

@ -132,7 +132,7 @@ class thread_ctrl final
// Remotely set or caught exception
std::exception_ptr m_exception;
// Thread initial task or atexit task
// Thread initial task
task_stack m_task;
// Fixed name
@ -150,9 +150,6 @@ class thread_ctrl final
// Called at the thread end
void finalize(std::exception_ptr) noexcept;
// Add task (atexit)
static void _push(task_stack);
// Internal waiting function, may throw. Infinite value is -1.
static bool _wait_for(u64 usec);
@ -241,13 +238,6 @@ public:
return g_tls_this_thread;
}
// Register function at thread exit (for the current thread)
template<typename F>
static inline void atexit(F&& func)
{
_push(std::forward<F>(func));
}
// Create detached named thread
template<typename N, typename F>
static inline void spawn(N&& name, F&& func)