source: trunk/synergy/lib/mt/CLock.h@ 3003

Last change on this file since 3003 was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 1.2 KB
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
20class CMutex;
21class CCondVarBase;
22
23//! Mutual exclusion lock utility
24/*!
25This class locks a mutex or condition variable in the c'tor and unlocks
26it in the d'tor. It's easier and safer than manually locking and
27unlocking since unlocking must usually be done no matter how a function
28exits (including by unwinding due to an exception).
29*/
30class CLock {
31public:
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
39private:
40 // not implemented
41 CLock(const CLock&);
42 CLock& operator=(const CLock&);
43
44private:
45 const CMutex* m_mutex;
46};
47
48#endif
Note: See TracBrowser for help on using the repository browser.