summaryrefslogtreecommitdiff
path: root/src/thread.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-14 16:39:39 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-15 06:57:37 +0200
commitda8b8000bd2a84c04a3a9cd6ce57f9bc814595cf (patch)
treec35be3404a8133ba5c4ef2a203bb7fa6fc108e22 /src/thread.cpp
parente86827511b35231679085dc236e9744184ed4609 (diff)
thread_t rewritten in C style
thread_t is one of the classes where C++ syntax creates more problems then it solves. This patch converts it into simple C-style pseudo-class. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/thread.cpp')
-rw-r--r--src/thread.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/thread.cpp b/src/thread.cpp
index e7af627..961bee1 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -35,20 +35,20 @@ extern "C"
}
}
-void xs::thread_t::start (thread_fn *tfn_, void *arg_)
+void xs::thread_start (xs::thread_t *self_, thread_fn *tfn_, void *arg_)
{
- tfn = tfn_;
- arg =arg_;
- descriptor = (HANDLE) _beginthreadex (NULL, 0,
- &::thread_routine, this, 0 , NULL);
- win_assert (descriptor != NULL);
+ self_->tfn = tfn_;
+ self_->arg =arg_;
+ self_->handle = (HANDLE) _beginthreadex (NULL, 0,
+ &::thread_routine, self_, 0 , NULL);
+ win_assert (self_->handle != NULL);
}
-void xs::thread_t::stop ()
+void xs::thread_stop (xs::thread_t *self_)
{
- DWORD rc = WaitForSingleObject (descriptor, INFINITE);
+ DWORD rc = WaitForSingleObject (self_->handle, INFINITE);
win_assert (rc != WAIT_FAILED);
- BOOL rc2 = CloseHandle (descriptor);
+ BOOL rc2 = CloseHandle (self_->handle);
win_assert (rc2 != 0);
}
@@ -76,23 +76,19 @@ extern "C"
}
}
-void xs::thread_t::start (thread_fn *tfn_, void *arg_)
+void xs::thread_start (xs::thread_t *self_, thread_fn *tfn_, void *arg_)
{
- tfn = tfn_;
- arg =arg_;
- int rc = pthread_create (&descriptor, NULL, thread_routine, this);
+ self_->tfn = tfn_;
+ self_->arg =arg_;
+ int rc = pthread_create (&self_->handle, NULL, thread_routine, self_);
posix_assert (rc);
}
-void xs::thread_t::stop ()
+void xs::thread_stop (xs::thread_t *self_)
{
- int rc = pthread_join (descriptor, NULL);
+ int rc = pthread_join (self_->handle, NULL);
posix_assert (rc);
}
#endif
-
-
-
-