Fawkes API Fawkes Development Version
semset.h
1
2/***************************************************************************
3 * semset.h - IPC semaphore set
4 *
5 * Generated: Tue Sep 19 14:45:47 2006
6 * Copyright 2006 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _UTILS_IPC_SEMSET_H_
25#define _UTILS_IPC_SEMSET_H_
26
27namespace fawkes {
28
29class SemaphoreSetData;
30
32{
33public:
34 SemaphoreSet(const char *path,
35 char id,
36 int num_sems,
37 bool create = false,
38 bool destroy_on_delete = false);
39
40 SemaphoreSet(int key, int num_sems, bool create = false, bool destroy_on_delete = false);
41
42 SemaphoreSet(int num_sems, bool destroy_on_delete = false);
43
45
46 bool valid();
47 void lock(unsigned short sem_num = 0, short num = 1);
48 bool try_lock(unsigned short sem_num = 0, short num = 1);
49 void unlock(unsigned short sem_num = 0, short num = -1);
50 void set_value(int sem_num, int val);
51 int get_value(int sem_num);
52 int key();
54
55 static int free_key();
56 static void destroy(int key);
57
58protected:
60
61private:
62 SemaphoreSetData *data;
63};
64
65} // end namespace fawkes
66
67#endif
IPC semaphore set.
Definition: semset.h:32
bool destroy_on_delete
Destroy this semaphore on delete?
Definition: semset.h:59
void set_destroy_on_delete(bool destroy)
Set if semaphore set should be destroyed on delete.
Definition: semset.cpp:365
bool valid()
Check if the semaphore set is valid.
Definition: semset.cpp:205
void unlock(unsigned short sem_num=0, short num=-1)
Unlock resources on the semaphore set.
Definition: semset.cpp:299
int get_value(int sem_num)
Get the semaphore value.
Definition: semset.cpp:341
bool try_lock(unsigned short sem_num=0, short num=1)
Try to lock resources on the semaphore set.
Definition: semset.cpp:270
void lock(unsigned short sem_num=0, short num=1)
Lock resources on the semaphore set.
Definition: semset.cpp:244
SemaphoreSet(const char *path, char id, int num_sems, bool create=false, bool destroy_on_delete=false)
Constructor.
Definition: semset.cpp:97
~SemaphoreSet()
Destructor.
Definition: semset.cpp:190
int key()
Get key of semaphore.
Definition: semset.cpp:353
static void destroy(int key)
Destroy a semaphore set.
Definition: semset.cpp:404
static int free_key()
Get a non-zero free key Scans the key space sequentially until a non-zero unused key is found.
Definition: semset.cpp:381
void set_value(int sem_num, int val)
Set the semaphore value.
Definition: semset.cpp:322
Fawkes library namespace.