00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __JackProcessSync__
00021 #define __JackProcessSync__
00022
00023 #include "JackPlatformPlug.h"
00024 #include <pthread.h>
00025 #include <sys/time.h>
00026 #include <unistd.h>
00027
00028 namespace Jack
00029 {
00030
00035 class JackProcessSync
00036 {
00037
00038 private:
00039
00040 pthread_mutex_t fLock;
00041 pthread_cond_t fCond;
00042
00043 public:
00044
00045 JackProcessSync()
00046 {
00047 pthread_mutex_init(&fLock, NULL);
00048 pthread_cond_init(&fCond, NULL);
00049 }
00050
00051 ~JackProcessSync()
00052 {
00053 pthread_mutex_destroy(&fLock);
00054 pthread_cond_destroy(&fCond);
00055 }
00056
00057 bool Allocate(const char* name)
00058 {
00059 return true;
00060 }
00061
00062 bool Connect(const char* name)
00063 {
00064 return true;
00065 }
00066
00067 void Destroy()
00068 {}
00069
00070 bool TimedWait(long usec);
00071
00072 void Wait();
00073
00074 void Signal()
00075 {
00076 pthread_mutex_lock(&fLock);
00077 pthread_cond_signal(&fCond);
00078 pthread_mutex_unlock(&fLock);
00079 }
00080
00081 void SignalAll()
00082 {
00083
00084 pthread_cond_broadcast(&fCond);
00085
00086 }
00087
00088 };
00089
00094 class JackInterProcessSync
00095 {
00096
00097 private:
00098
00099 JackSynchro* fSynchro;
00100
00101 public:
00102
00103 JackInterProcessSync(JackSynchro* synchro): fSynchro(synchro)
00104 {}
00105 ~JackInterProcessSync()
00106 {
00107 delete fSynchro;
00108 }
00109
00110 bool Allocate(const char* name)
00111 {
00112 return fSynchro->Allocate(name, "", 0);
00113 }
00114
00115 void Destroy()
00116 {
00117 fSynchro->Destroy();
00118 }
00119
00120 bool Connect(const char* name)
00121 {
00122 return fSynchro->Connect(name, "");
00123 }
00124
00125 bool TimedWait(long usec);
00126
00127 void Wait()
00128 {
00129 fSynchro->Wait();
00130 }
00131
00132 void SignalAll()
00133 {
00134 fSynchro->SignalAll();
00135 }
00136 };
00137
00138
00139 }
00140
00141 #endif
00142