00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __UTILS_IPC_SEMSET_H_
00025 #define __UTILS_IPC_SEMSET_H_
00026
00027 namespace fawkes {
00028
00029
00030 class SemaphoreSetData;
00031
00032 class SemaphoreSet {
00033 public:
00034
00035 SemaphoreSet(const char *path, char id,
00036 int num_sems,
00037 bool create = false,
00038 bool destroy_on_delete = false);
00039
00040 SemaphoreSet(int key,
00041 int num_sems,
00042 bool create = false,
00043 bool destroy_on_delete = false);
00044
00045 SemaphoreSet( int num_sems,
00046 bool destroy_on_delete = false);
00047
00048 ~SemaphoreSet();
00049
00050 bool valid();
00051 void lock(unsigned short sem_num = 0, short num = 1);
00052 bool try_lock(unsigned short sem_num = 0, short num = 1);
00053 void unlock(unsigned short sem_num = 0, short num = -1);
00054 void set_value(int sem_num, int val);
00055 int get_value(int sem_num);
00056 int key();
00057 void set_destroy_on_delete(bool destroy);
00058
00059 static int free_key();
00060 static void destroy(int key);
00061
00062 protected:
00063 bool destroy_on_delete;
00064
00065 private:
00066 SemaphoreSetData *data;
00067
00068 };
00069
00070
00071 }
00072
00073 #endif