semset.h

00001 
00002 /***************************************************************************
00003  *  semset.h - IPC semaphore set
00004  *
00005  *  Generated: Tue Sep 19 14:45:47 2006
00006  *  Copyright  2006  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
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 } // end namespace fawkes
00072 
00073 #endif

Generated on Tue Feb 22 13:32:28 2011 for Fawkes API by  doxygen 1.4.7