aboutsummaryrefslogtreecommitdiff
path: root/works/life/operating-system-experiment/Thread.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-10 11:12:25 +0800
committercrupest <crupest@outlook.com>2021-06-10 11:12:25 +0800
commitef593ba2d445af515214d63bfd3942be9d673467 (patch)
tree6f286d3c30af2a6c74a1a60047fa25bae09fd9db /works/life/operating-system-experiment/Thread.cpp
parent93d8feccd79b35fc890fc8629d6da2c2baa57762 (diff)
downloadcrupest-ef593ba2d445af515214d63bfd3942be9d673467.tar.gz
crupest-ef593ba2d445af515214d63bfd3942be9d673467.tar.bz2
crupest-ef593ba2d445af515214d63bfd3942be9d673467.zip
import(life): ...
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;