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

TArtSemaphore.h

00001 /*
00002  *    TArtSemaphore.hh
00003  *    Created       : Jan 19 2007 15:05:00
00004  *    Last Modified : Jan 19 2007 18:09:15
00005  *--------------------------------------------------------
00006  *    Comment : Manage and control a semaphore 
00007  *    
00008  *--------------------------------------------------------
00009  *    Copyright (C)2007 by ota
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

Generated on Mon Sep 8 08:58:21 2008 by  doxygen 1.3.9.1