PaCO++
0.05
|
00001 #include "paco_omni.h" 00002 00003 paco_omni_thread::paco_omni_thread() 00004 { 00005 } 00006 00007 paco_omni_thread::~paco_omni_thread() 00008 { 00009 } 00010 00011 paco_omni_mutex::paco_omni_mutex() 00012 { 00013 mutex = new omni_mutex(); 00014 } 00015 00016 paco_omni_mutex::~paco_omni_mutex() 00017 { 00018 delete mutex; 00019 } 00020 00021 void 00022 paco_omni_mutex::lock() 00023 { 00024 mutex->lock(); 00025 } 00026 00027 void 00028 paco_omni_mutex::unlock() 00029 { 00030 mutex->unlock(); 00031 } 00032 00033 paco_omni_condition::paco_omni_condition(paco_omni_mutex* m) 00034 { 00035 condition = new omni_condition(m->mutex); 00036 } 00037 00038 paco_omni_condition::~paco_omni_condition() 00039 { 00040 delete condition; 00041 } 00042 00043 void 00044 paco_omni_condition::wait() 00045 { 00046 condition->wait(); 00047 }; 00048 00049 void 00050 paco_omni_condition::signal() 00051 { 00052 condition->signal(); 00053 }; 00054 00055 paco_mutex* paco_omni_fabrique::paco_create_mutex() 00056 { 00057 return new paco_omni_mutex(); 00058 } 00059 00060 paco_condition* paco_omni_fabrique::paco_create_condition(paco_mutex * mutex) 00061 { 00062 return new paco_omni_condition((paco_omni_mutex*) mutex); 00063 } 00064 00065 paco_thread * paco_omni_fabrique::paco_create_thread(void* (*fn)(void*), void* arg) 00066 { 00067 // paco_omni_thread * th = new paco_omni_thread(); 00068 // to have a detached thread ! 00069 void (*fn_detached)(void*) = (void (*)(void *))fn; 00070 //th->thread = omni_thread::create(fn_detached,arg); 00071 try 00072 { 00073 omni_thread::create(fn_detached,arg); 00074 } 00075 catch (omni_thread_fatal &e) 00076 { 00077 int end = 0; 00078 while (end != 1) 00079 { 00080 cerr << "paco_create_thread error : " << e.error << endl; 00081 end = end + 1; 00082 omni_thread::sleep(2); 00083 try 00084 { 00085 omni_thread::create(fn_detached,arg); 00086 } 00087 catch (omni_thread_fatal &e) 00088 { 00089 end = end - 1; 00090 } 00091 } 00092 } 00093 //return th; 00094 return NULL; 00095 } 00096 00097 paco_thread * paco_omni_fabrique::paco_create_thread(void (*fn)(void*), void* arg) 00098 { 00099 try 00100 { 00101 omni_thread::create(fn,arg); 00102 } 00103 catch (omni_thread_fatal &e) 00104 { 00105 int end = 0; 00106 while (end != 1) 00107 { 00108 cerr << "paco_create_thread error : " << e.error << endl; 00109 end = end + 1; 00110 omni_thread::sleep(2); 00111 try 00112 { 00113 omni_thread::create(fn,arg); 00114 } 00115 catch (omni_thread_fatal &e) 00116 { 00117 end = end - 1; 00118 } 00119 } 00120 } 00121 return NULL; 00122 }