aboutsummaryrefslogtreecommitdiff
path: root/operating-system-experiment/Thread.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-10 11:55:27 +0800
committercrupest <crupest@outlook.com>2021-06-10 11:55:27 +0800
commit10b7a5e29e48b874dbec2732c0396160bdcd5b01 (patch)
treee76d14c21984ee0063ad634d9212ac33a5991eac /operating-system-experiment/Thread.h
parentac67d8556835e2c37fd9e96199432750dbb40ba9 (diff)
downloadlife-10b7a5e29e48b874dbec2732c0396160bdcd5b01.tar.gz
life-10b7a5e29e48b874dbec2732c0396160bdcd5b01.tar.bz2
life-10b7a5e29e48b874dbec2732c0396160bdcd5b01.zip
...
Diffstat (limited to 'operating-system-experiment/Thread.h')
-rw-r--r--operating-system-experiment/Thread.h12
1 files changed, 2 insertions, 10 deletions
diff --git a/operating-system-experiment/Thread.h b/operating-system-experiment/Thread.h
index 56fdcb0..735407c 100644
--- a/operating-system-experiment/Thread.h
+++ b/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