diff options
author | crupest <crupest@outlook.com> | 2021-06-10 11:55:27 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-10 11:55:27 +0800 |
commit | 5018c2b40009258ed0691cbbb1dcc4d8ac4a809b (patch) | |
tree | 1c4269b73b0473f47b98ca260676dbec1460791f /works/life/operating-system-experiment/Thread.h | |
parent | 06c91dd3a3d17bd1f884c7e322fd7701a95ce7a9 (diff) | |
download | crupest-5018c2b40009258ed0691cbbb1dcc4d8ac4a809b.tar.gz crupest-5018c2b40009258ed0691cbbb1dcc4d8ac4a809b.tar.bz2 crupest-5018c2b40009258ed0691cbbb1dcc4d8ac4a809b.zip |
import(life): ...
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
|