00001
00002 #ifndef SEMAPHORE_HH
00003 #define SEMAPHORE_HH
00004
00005 extern "C"
00006 {
00007 #include "_sem.h"
00008 #ifndef UNDER_CE
00009 #include <sys/stat.h>
00010 #endif
00011 }
00012
00013 #ifndef WIN32
00014 #define DEFAULT_SEM_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
00015 #else
00016 #define DEFAULT_SEM_MODE (0)
00017 #endif
00018
00019 #define RCS_SEMAPHORE_NOCREATE 0x00
00020 #define RCS_SEMAPHORE_CREATE 0x01
00021
00022 class RCS_SEMAPHORE
00023 {
00024 public:
00025 RCS_SEMAPHORE (unsigned long int id, int oflag, double _timeout,
00026 int mode = DEFAULT_SEM_MODE, int state = 0);
00027 ~RCS_SEMAPHORE ();
00028 int wait ();
00029 int trywait ();
00030 int post ();
00031 int flush ();
00032 int getvalue ();
00033
00034 int setflag (int oflag);
00035
00036
00037
00038 int valid ();
00039 int clear ();
00040
00041
00042 unsigned long int id;
00043 double timeout;
00044 int oflag;
00045 int mode;
00046 int state;
00047 rcs_sem_t *sem;
00048 unsigned int sval;
00049
00050 private:
00051 RCS_SEMAPHORE (RCS_SEMAPHORE & sem);
00052
00053 };
00054
00055 #endif