PTLib
Version 2.14.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
mutex.h
Go to the documentation of this file.
1
/*
2
* mutex.h
3
*
4
* Mutual exclusion thread synchonisation class.
5
*
6
* Portable Windows Library
7
*
8
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9
*
10
* The contents of this file are subject to the Mozilla Public License
11
* Version 1.0 (the "License"); you may not use this file except in
12
* compliance with the License. You may obtain a copy of the License at
13
* http://www.mozilla.org/MPL/
14
*
15
* Software distributed under the License is distributed on an "AS IS"
16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17
* the License for the specific language governing rights and limitations
18
* under the License.
19
*
20
* The Original Code is Portable Windows Library.
21
*
22
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23
*
24
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25
* All Rights Reserved.
26
*
27
* Contributor(s): ______________________________________.
28
*
29
* $Revision: 28062 $
30
* $Author: rjongbloed $
31
* $Date: 2012-07-19 19:45:52 +1000 (Thu, 19 Jul 2012) $
32
*/
33
34
#ifndef PTLIB_MUTEX_H
35
#define PTLIB_MUTEX_H
36
37
#ifdef P_USE_PRAGMA
38
#pragma interface
39
#endif
40
41
#include <
ptlib/critsec.h
>
42
#include <
ptlib/semaphor.h
>
43
65
class
PTimedMutex
:
public
PSync
66
{
67
PCLASSINFO
(
PTimedMutex
,
PSync
)
68
public
:
69
/* Create a new mutex.
70
Initially the mutex will not be "set", so the first call to Wait() will
71
never wait.
72
*/
73
PTimedMutex
();
74
78
PTimedMutex
(
const
PTimedMutex
& mutex);
79
83
PTimedMutex
&
operator=
(
const
PTimedMutex
&) {
return
*
this
; }
84
87
virtual
void
Wait
();
88
94
virtual
PBoolean
Wait
(
95
const
PTimeInterval
& timeout
// Amount of time to wait.
96
);
97
100
virtual
void
Signal
();
101
105
PINLINE
bool
Try
() {
return
Wait
(0); }
106
107
108
private
:
109
PThreadIdentifier m_lockerId;
110
PAtomicInteger
m_lockCount;
111
112
// Include platform dependent part of class
113
#ifdef _WIN32
114
#include "msos/ptlib/mutex.h"
115
#else
116
#include "unix/ptlib/mutex.h"
117
#endif
118
};
119
120
// On Windows, critical sections are recursive and so we can use them for mutexes
121
// The only Posix mutex that is recursive is pthread_mutex, so we have to use that
122
#ifdef _WIN32
123
126
typedef
PCriticalSection
PMutex
;
127
#else
128
131
typedef
PTimedMutex
PMutex
;
132
#define PCriticalSection PTimedMutex
133
#endif
134
135
136
#endif // PTLIB_MUTEX_H
137
138
139
// End Of File ///////////////////////////////////////////////////////////////
include
ptlib
mutex.h
Generated on Fri Oct 10 2014 21:15:13 for PTLib by
1.8.3.1