Line | |
---|
1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2002 Chris Schoeneman
|
---|
4 | *
|
---|
5 | * This package is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * found in the file COPYING that should have accompanied this file.
|
---|
8 | *
|
---|
9 | * This package is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | * GNU General Public License for more details.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef CLOCK_H
|
---|
16 | #define CLOCK_H
|
---|
17 |
|
---|
18 | #include "common.h"
|
---|
19 |
|
---|
20 | class CMutex;
|
---|
21 | class CCondVarBase;
|
---|
22 |
|
---|
23 | //! Mutual exclusion lock utility
|
---|
24 | /*!
|
---|
25 | This class locks a mutex or condition variable in the c'tor and unlocks
|
---|
26 | it in the d'tor. It's easier and safer than manually locking and
|
---|
27 | unlocking since unlocking must usually be done no matter how a function
|
---|
28 | exits (including by unwinding due to an exception).
|
---|
29 | */
|
---|
30 | class CLock {
|
---|
31 | public:
|
---|
32 | //! Lock the mutex \c mutex
|
---|
33 | CLock(const CMutex* mutex);
|
---|
34 | //! Lock the condition variable \c cv
|
---|
35 | CLock(const CCondVarBase* cv);
|
---|
36 | //! Unlock the mutex or condition variable
|
---|
37 | ~CLock();
|
---|
38 |
|
---|
39 | private:
|
---|
40 | // not implemented
|
---|
41 | CLock(const CLock&);
|
---|
42 | CLock& operator=(const CLock&);
|
---|
43 |
|
---|
44 | private:
|
---|
45 | const CMutex* m_mutex;
|
---|
46 | };
|
---|
47 |
|
---|
48 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.