00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 00003 // -- BEGIN LICENSE BLOCK ---------------------------------------------- 00004 // This file is part of FZIs ic_workspace. 00005 // 00006 // This program is free software licensed under the LGPL 00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3). 00008 // You can find a copy of this license in LICENSE folder in the top 00009 // directory of the source code. 00010 // 00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany 00012 // 00013 // -- END LICENSE BLOCK ------------------------------------------------ 00014 00015 //---------------------------------------------------------------------- 00022 //---------------------------------------------------------------------- 00023 #include "ThreadImplPosix.h" 00024 00025 #include "Thread.h" 00026 00027 namespace icl_core { 00028 namespace logging { 00029 00030 ThreadImplPosix::ThreadImplPosix(Thread *thread, icl_core::ThreadPriority priority) 00031 : m_thread_id(0), 00032 m_thread(thread), 00033 m_priority(priority) 00034 { } 00035 00036 ThreadImplPosix::~ThreadImplPosix() 00037 { } 00038 00039 void ThreadImplPosix::join() 00040 { 00041 pthread_join(m_thread_id, NULL); 00042 } 00043 00044 bool ThreadImplPosix::start() 00045 { 00046 if (pthread_create(&m_thread_id, NULL, ThreadImplPosix::runThread, this)) 00047 { 00048 m_thread_id = 0; 00049 } 00050 00051 return m_thread_id != 0; 00052 } 00053 00054 void *ThreadImplPosix::runThread(void *arg) 00055 { 00056 ThreadImplPosix *self = static_cast<ThreadImplPosix*>(arg); 00057 self->m_thread->runThread(); 00058 00059 return NULL; 00060 } 00061 00062 } 00063 }