File: MutexSet.h

package info (click to toggle)
kwave 0.7.2-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,048 kB
  • ctags: 4,906
  • sloc: cpp: 31,275; ansic: 13,111; sh: 9,511; perl: 2,724; makefile: 786; asm: 145
file content (62 lines) | stat: -rw-r--r-- 1,965 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/***************************************************************************
             MutexSet.h  -  set of mutexes
			     -------------------
    begin                : Feb 11 2001
    copyright            : (C) 2001 by Thomas Eschenbacher
    email                : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _MUTEX_SET_H_
#define _MUTEX_SET_H_

#include "config.h"
#include <qptrlist.h>
#include "mt/TSS_Object.h"

class Mutex;
class MutexGuard;

/**
 * @class MutexSet
 * Holds a set of mutexes and locks by locking each added mutex through
 * a mutex guard. If the mutex set is deleted, it automatically releases
 * all mutexes.
 */
class MutexSet: public TSS_Object
{
public:
    /** Default constructor */
    MutexSet();

    /** Destructor, releases all mutexes */
    virtual ~MutexSet();

    /**
     * Takes over all mutexes from an existing mutex set.
     * Use this with care!
     */
    void takeOver(MutexSet &set);

    /**
     * Creates a mutex guard and lock the passed mutex.
     * @param mutex the mutex to be locked.
     * @return true if ok, false if not enough memory
     */
    bool addLock(Mutex &mutex);

protected:

    /** list of mutex guards */
    QPtrList<MutexGuard> m_guards;
};

#endif /* _MUTEX_SET_H_ */