aboutsummaryrefslogtreecommitdiff
path: root/works/life/operating-system-experiment/Thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'works/life/operating-system-experiment/Thread.cpp')
-rw-r--r--works/life/operating-system-experiment/Thread.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/works/life/operating-system-experiment/Thread.cpp b/works/life/operating-system-experiment/Thread.cpp
index 9d9f5dd..7e3c784 100644
--- a/works/life/operating-system-experiment/Thread.cpp
+++ b/works/life/operating-system-experiment/Thread.cpp
@@ -59,6 +59,36 @@ void Thread::Detach() {
detached_ = true;
}
+#ifdef CRU_WINDOWS
+DWORD
+#else
+pthread_t
+#endif
+Thread::GetNativeID() {
+#ifdef CRU_WINDOWS
+ assert(thread_handle_);
+ return thread_id_;
+#else
+ assert(thread_);
+ return *thread_;
+#endif
+}
+
+#ifdef CRU_WINDOWS
+HANDLE
+#else
+pthread_t
+#endif
+Thread::GetNativeHandle() {
+#ifdef CRU_WINDOWS
+ assert(thread_handle_);
+ return thread_handle_;
+#else
+ assert(thread_);
+ return *thread_;
+#endif
+}
+
void Thread::swap(Thread &other) noexcept {
#ifdef CRU_WINDOWS
Thread temp = std::move(*this);
@@ -81,6 +111,7 @@ void Thread::Destroy() noexcept {
detached_ = false;
joined_ = false;
#ifdef CRU_WINDOWS
+ thread_id_ = 0;
thread_handle_ = nullptr;
#else
thread_ = nullptr;