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
psync.h
Go to the documentation of this file.
1
/*
2
* psync.h
3
*
4
* Abstract synchronisation semaphore class.
5
*
6
* Portable Tools Library
7
*
8
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9
* Copyright (c) 2005 Post Increment
10
*
11
* The contents of this file are subject to the Mozilla Public License
12
* Version 1.0 (the "License"); you may not use this file except in
13
* compliance with the License. You may obtain a copy of the License at
14
* http://www.mozilla.org/MPL/
15
*
16
* Software distributed under the License is distributed on an "AS IS"
17
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18
* the License for the specific language governing rights and limitations
19
* under the License.
20
*
21
* The Original Code is Portable Windows Library.
22
*
23
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24
*
25
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
26
* All Rights Reserved.
27
*
28
* Contributor(s): ______________________________________.
29
*
30
* $Revision: 28065 $
31
* $Author: rjongbloed $
32
* $Date: 2012-07-19 21:01:53 +1000 (Thu, 19 Jul 2012) $
33
*/
34
35
#ifndef PTLIB_SYNC_H
36
#define PTLIB_SYNC_H
37
38
#ifdef P_USE_PRAGMA
39
#pragma interface
40
#endif
41
42
#include <
ptlib/contain.h
>
43
#include <
ptlib/object.h
>
44
45
46
class
PTimeInterval
;
47
48
49
class
PSync
:
public
PObject
50
{
51
public
:
52
PSync
() { }
53
58
virtual
void
Wait
() = 0;
59
65
virtual
PBoolean
Wait
(
66
const
PTimeInterval
& timeout
// Amount of time to wait.
67
) = 0;
68
71
virtual
void
Signal
() = 0;
73
74
private
:
75
PSync
(
const
PSync
&) :
PObject
() { }
76
void
operator=(
const
PSync
&) { }
77
};
78
79
81
class
PSyncNULL
:
public
PSync
82
{
83
public
:
84
virtual
void
Wait
() { }
85
virtual
PBoolean
Wait
(
const
PTimeInterval
&) {
return
true
; }
86
virtual
void
Signal
() { }
87
88
private
:
89
PSyncNULL
(
const
PSyncNULL
&) :
PSync
() { }
90
void
operator=(
const
PSyncNULL
&) { }
91
};
92
93
113
class
PWaitAndSignal
{
114
public
:
119
inline
PWaitAndSignal
(
120
const
PSync
& sem,
121
PBoolean
wait =
true
122
) :
sync
((
PSync
&)sem)
123
{
if
(wait)
sync
.
Wait
(); }
124
129
~PWaitAndSignal
()
130
{
sync
.
Signal
(); }
131
132
protected
:
133
PSync
&
sync
;
134
};
135
136
137
#endif // PTLIB_SYNC_H
138
139
140
// End Of File ///////////////////////////////////////////////////////////////
include
ptlib
psync.h
Generated on Fri Oct 10 2014 21:15:13 for PTLib by
1.8.3.1