Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

sema.h

Go to the documentation of this file.
00001 #ifndef SEMA_H
00002 #define SEMA_H
00003 
00004 
00005 #include <semaphore.h>
00006 
00007 class Sema
00008 {
00009 public:
00010         Sema(int init_value = 1, char *title = 0);
00011         ~Sema();
00012 
00013         void lock(char *location = 0);
00014         void unlock();
00015         int get_value();
00016         void reset();
00017 
00018         sem_t sem;
00019         char *title;
00020         int init_value;
00021 };
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #if 0
00031 
00032 
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <sys/ipc.h>
00036 #include <sys/sem.h>
00037 #include <sys/types.h>
00038 
00039 union semun {
00040    int val; /* used for SETVAL only */
00041    struct semid_ds *buf; /* for IPC_STAT and IPC_SET */
00042    ushort *array;  /* used for GETALL and SETALL */
00043 };
00044 
00045 class Sema
00046 {
00047 public:
00048         Sema(int id = -1, int number = 1);
00049         ~Sema();
00050 
00051         int lock(int number = 0);
00052         int unlock(int number = 0);
00053         int get_value(int number = 0);
00054         int get_id();
00055 
00056         int semid;
00057         int client;
00058         int semas;
00059         semun arg;
00060 };
00061 
00062 #endif
00063 
00064 
00065 
00066 
00067 
00068 #endif

Generated on Sun Jan 8 13:26:35 2006 for Guicast-svn by  doxygen 1.4.4