Line | |
---|
1 |
/* |
---|
2 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB |
---|
8 |
* |
---|
9 |
* This program is free software: you can redistribute it and/or modify |
---|
10 |
* it under the terms of the GNU General Public License as published by |
---|
11 |
* the Free Software Foundation, either version 2 of the License, or |
---|
12 |
* (at your option) version 3 of the License. |
---|
13 |
* |
---|
14 |
* This program is distributed in the hope that it will be useful, |
---|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 |
* GNU General Public License for more details. |
---|
18 |
* |
---|
19 |
* You should have received a copy of the GNU General Public License |
---|
20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
21 |
* |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#ifndef __POSIX_MUTEX__ |
---|
25 |
#define __POSIX_MUTEX__ |
---|
26 |
|
---|
27 |
|
---|
28 |
|
---|
29 |
#include "Mutex.h" |
---|
30 |
#include <pthread.h> |
---|
31 |
#include <string> |
---|
32 |
|
---|
33 |
#include "debugmodule/debugmodule.h" |
---|
34 |
|
---|
35 |
namespace Util |
---|
36 |
{ |
---|
37 |
|
---|
38 |
/** |
---|
39 |
* @brief The POSIX mutex implementation. |
---|
40 |
*/ |
---|
41 |
|
---|
42 |
class PosixMutex : public Mutex |
---|
43 |
{ |
---|
44 |
public: |
---|
45 |
PosixMutex(); |
---|
46 |
PosixMutex(std::string id); |
---|
47 |
virtual ~PosixMutex(); |
---|
48 |
|
---|
49 |
virtual void Lock(); |
---|
50 |
virtual bool TryLock(); |
---|
51 |
virtual void Unlock(); |
---|
52 |
|
---|
53 |
virtual bool isLocked(); |
---|
54 |
|
---|
55 |
virtual void show(); |
---|
56 |
virtual void setVerboseLevel(int l) {setDebugLevel(l);}; |
---|
57 |
|
---|
58 |
protected: |
---|
59 |
DECLARE_DEBUG_MODULE; |
---|
60 |
|
---|
61 |
private: |
---|
62 |
pthread_mutex_t m_mutex; |
---|
63 |
|
---|
64 |
std::string m_id; |
---|
65 |
|
---|
66 |
#if DEBUG_LOCK_COLLISION_TRACING |
---|
67 |
void *m_locked_by; |
---|
68 |
#endif |
---|
69 |
}; |
---|
70 |
|
---|
71 |
} // end of namespace |
---|
72 |
|
---|
73 |
#endif |
---|