ThreadImplWin32.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 //----------------------------------------------------------------------
00009 //----------------------------------------------------------------------
00010 #include "ThreadImplWin32.h"
00011 
00012 #include "Thread.h"
00013 
00014 namespace icl_core {
00015 namespace logging {
00016 
00017 ThreadImplWin32::ThreadImplWin32(Thread *thread, icl_core::ThreadPriority priority)
00018   : m_thread_handle(0),
00019     m_thread(thread)
00020 {
00021 }
00022 
00023 ThreadImplWin32::~ThreadImplWin32()
00024 {
00025   if (m_thread_handle != 0)
00026   {
00027     ::CloseHandle(m_thread_handle);
00028   }
00029 }
00030 
00031 void ThreadImplWin32::join()
00032 {
00033   DWORD result = ::WaitForSingleObject(m_thread_handle, INFINITE);
00034   if (result == WAIT_OBJECT_0)
00035   {
00036     m_thread_id = 0;
00037   }
00038   else
00039   {
00040     // TODO: Error handling!
00041   }
00042 }
00043 
00044 bool ThreadImplWin32::start()
00045 {
00046   m_thread_id = 0;
00047   m_thread_handle = ::CreateThread(NULL, 0, ThreadImplWin32::runThread, this, 0, NULL);
00048 
00049   return m_thread_handle != 0;
00050 }
00051 
00052 DWORD WINAPI ThreadImplWin32::runThread(void *arg)
00053 {
00054   ThreadImplWin32 *self = static_cast<ThreadImplWin32*>(arg);
00055 
00056   self->m_thread_id = ::GetCurrentThreadId();
00057   self->m_thread->runThread();
00058 
00059   return 0;
00060 }
00061 
00062 }
00063 }


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19