PTLib
Version 2.10.4
Main Page
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: 24177 $
31
* $Author: rjongbloed $
32
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
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
class
PSync
:
public
PObject
46
{
47
public
:
52
virtual
void
Wait
() = 0;
53
56
virtual
void
Signal
() = 0;
58
59
#ifdef P_PTHREADS
60
PSync
()
61
: lockerId(pthread_t(-1)) { }
62
protected
:
63
pthread_t lockerId;
64
#endif
65
};
66
67
class
PSyncNULL
:
public
PSync
68
{
69
public
:
70
virtual
void
Wait
() { }
71
virtual
void
Signal
() { }
72
};
73
93
class
PWaitAndSignal
{
94
public
:
99
inline
PWaitAndSignal
(
100
const
PSync
& sem,
101
PBoolean
wait =
true
102
) :
sync
((
PSync
&)sem)
103
{
if
(wait)
sync
.
Wait
(); }
104
109
~PWaitAndSignal
()
110
{
sync
.
Signal
(); }
111
112
protected
:
113
PSync
&
sync
;
114
};
115
116
117
#endif // PTLIB_SYNC_H
118
119
120
// End Of File ///////////////////////////////////////////////////////////////
include
ptlib
psync.h
Generated on Tue Mar 11 2014 15:09:30 for PTLib by
1.8.1.2