diff options
Diffstat (limited to 'works/life/operating-system-experiment/Thread.h')
-rw-r--r-- | works/life/operating-system-experiment/Thread.h | 12 |
1 files changed, 2 insertions, 10 deletions
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<void()> *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<void *>(p), 0, &thread_id_);
- assert(thread_handle_);
-#else
- thread_.reset(new pthread_t());
- auto c = pthread_create(thread_.get(), nullptr, details::ThreadProc,
- static_cast<void *>(p));
- assert(c == 0);
-#endif
+ CreateThread(p);
};
} // namespace cru
|