thread.cpp

Go to the documentation of this file.
00001 //======================================================================
00002 // File:        thread.cpp
00003 // Author:      Matthias Toussaint
00004 // Created:     Sat Nov 25 18:56:16 CET 2006
00005 // Project:     QtDMM
00006 // Description: Simplest possible posix thread class
00007 //----------------------------------------------------------------------
00008 // This file  may  be used under  the terms of  the GNU  General Public
00009 // License  version 2.0 as published   by the Free Software  Foundation
00010 // and appearing  in the file LICENSE.GPL included  in the packaging of
00011 // this file.
00012 // 
00013 // This file is provided AS IS with  NO WARRANTY OF ANY KIND, INCLUDING 
00014 // THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00015 // PURPOSE.
00016 //----------------------------------------------------------------------
00017 // Copyright 2006 Matthias Toussaint
00018 //======================================================================
00019 
00020 #include <thread.h>
00021 
00022 Thread::Thread()
00023 {
00024 }
00025 
00026 Thread::~Thread()
00027 {
00028 }
00029 
00030 void *Thread::start_thread( void *ptr )
00031 {
00032   Thread *thread = (Thread *)ptr;
00033   
00034   thread->run();
00035   
00036   return ptr;
00037 }
00038 
00039 int Thread::start()
00040 {
00041   m_run = true;
00042   pthread_attr_t attrs;
00043   ::pthread_attr_init( &attrs );
00044   return ::pthread_create( &m_pthread, &attrs, Thread::start_thread, this );
00045 }
00046 
00047 void Thread::wait()
00048 {
00049   ::pthread_join( m_pthread, 0 );
00050 }
00051 
00052 void Thread::quit()
00053 {
00054   ::pthread_exit( 0 );
00055 }

Generated on Mon Jan 22 23:24:18 2007 for cdmm by  doxygen 1.4.6