cThread.cpp

00001 // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
00002 // This file is part of the "cAudio Engine"
00003 // For conditions of distribution and use, see copyright notice in cAudio.h
00004 
00005 #include "../Headers/cThread.h"
00006 
00007 #ifdef CAUDIO_PLATFORM_WIN
00008 #include <windows.h>    //Basic windows includes
00009 #include <process.h>
00010 #else
00011 #include <pthread.h>    //Assumed linux system
00012 #endif  
00013 
00014 namespace cAudio
00015 {
00016         #ifdef CAUDIO_PLATFORM_WIN
00017         int cAudioThread::SpawnThread( unsigned __stdcall start_address( void* ), void *arg)
00018         {
00019                 HANDLE threadHandle;
00020                 unsigned threadID = 0;
00021 
00022                 threadHandle = (HANDLE) _beginthreadex(NULL,0,start_address,arg,0,&threadID);
00023 
00024                 int state = (threadHandle==0) ? 1 : 0;
00025 
00026                 if(state == 0)
00027                         CloseHandle( threadHandle );
00028 
00029                 return state;
00030         }
00031         #else
00032         int cAudioThread::SpawnThread( void* start_address( void* ), void *arg)
00033         {
00034                 pthread_t threadHandle;
00035 
00036                 pthread_attr_t attr;
00037                 pthread_attr_init( &attr );
00038                 pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
00039 
00040                 return pthread_create( &threadHandle, &attr, start_address, arg );
00041         }
00042         #endif
00043 };
 All Classes Namespaces Functions Variables Enumerations

Generated on Sat Feb 20 22:55:09 2010 for cAudio by  doxygen 1.6.2