From 5018c2b40009258ed0691cbbb1dcc4d8ac4a809b Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 10 Jun 2021 11:55:27 +0800 Subject: import(life): ... --- works/life/operating-system-experiment/Thread.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'works/life/operating-system-experiment/Thread.h') diff --git a/works/life/operating-system-experiment/Thread.h b/works/life/operating-system-experiment/Thread.h index 56fdcb0..735407c 100644 --- a/works/life/operating-system-experiment/Thread.h +++ b/works/life/operating-system-experiment/Thread.h @@ -52,6 +52,7 @@ public: private: void Destroy() noexcept; + void CreateThread(std::function *proc); private: bool detached_ = false; @@ -81,16 +82,7 @@ Thread::Thread(Fn &&process, Args &&...args) { std::apply(process, std::move(args)); }); -#ifdef CRU_WINDOWS - thread_handle_ = ::CreateThread(nullptr, 0, &::cru::details::ThreadProc, - static_cast(p), 0, &thread_id_); - assert(thread_handle_); -#else - thread_.reset(new pthread_t()); - auto c = pthread_create(thread_.get(), nullptr, details::ThreadProc, - static_cast(p)); - assert(c == 0); -#endif + CreateThread(p); }; } // namespace cru -- cgit v1.2.3