00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef TARTSEMAPHORE_H
00012 #define TARTSEMAPHORE_H
00013 #include <stdio.h>
00014 #include <sys/types.h>
00015 #include <sys/ipc.h>
00016 #include <sys/sem.h>
00017
00018 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
00019 #else
00020 union semun {
00021 int val;
00022 struct semid_ds* buf;
00023 unsigned short* array;
00024 struct seminfo* __buf;
00025 };
00026
00027 #endif
00028
00029 class TArtSemaphore {
00030
00031 public:
00032 TArtSemaphore(int semkey);
00033 ~TArtSemaphore();
00034 int Delete();
00035 void Lock();
00036 void Unlock();
00037 bool IsValid() {return fIsValid; }
00038 private:
00039 int fKey;
00040 int fID;
00041 bool fIsValid;
00042 union semun fSemUnion;
00043 struct sembuf fSemaphore;
00044 };
00045 #endif // end of #ifdef TARTSEMAPHORE_H