• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/util/src/Thread.cpp

Go to the documentation of this file.
00001 // Main header
00002 #include "../pch.h"
00003 
00004 Thread::Thread(){
00005         thread = 0;
00006 }
00007 
00008 Thread::Thread(const Thread& other){
00009         thread = other.thread;
00010 }
00011 
00012 bool Thread::start(Function function, void* param, uint stacksize, int priority){
00013         if(thread)
00014                 return false;
00015         unsigned long Win9598Me;
00016         thread = CreateThread(0, (size_t)stacksize, function, param, 0, &Win9598Me);
00017         if(priority != 0)
00018                 SetThreadPriority(thread, priority);
00019         return true;
00020 }
00021 
00022 bool Thread::end(void){
00023         BOOL result = 0;
00024         if(thread){
00025                 //result = TerminateThread(thread, 0);
00026                 thread = 0;
00027         }
00028         return result != 0;
00029 }
00030 
00031 bool Thread::valid(void){
00032         return thread != 0;
00033 }
00034 
00035 Section::Section(){
00036 }
00037 
00038 Section::Section(const Section& other){
00039         section = other.section;
00040 }
00041 
00042 void Section::init(void){
00043         InitializeCriticalSection(&section);
00044 }
00045 
00046 void Section::uninit(void){
00047         DeleteCriticalSection(&section);
00048 }
00049 
00050 void Section::enter(void){
00051         EnterCriticalSection(&section);
00052 }
00053 
00054 bool Section::tryenter(void){
00055         return TryEnterCriticalSection(&section) != 0;
00056 }
00057 
00058 void Section::leave(void){
00059         LeaveCriticalSection(&section);
00060 }

Generated on Fri Jun 18 2010 17:48:40 for Cannonball by  doxygen 1.7.0