source: box/trunk/lib/common/NamedLock.h @ 2536

Revision 2536, 960 bytes checked in by chris, 3 years ago (diff)

Make NamedLock? take a std::string instead of a char pointer for C++
style.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    NamedLock.h
5//              Purpose: A global named lock, implemented as a lock file in file system
6//              Created: 2003/08/28
7//
8// --------------------------------------------------------------------------
9
10#ifndef NAMEDLOCK__H
11#define NAMEDLOCK__H
12
13// --------------------------------------------------------------------------
14//
15// Class
16//              Name:    NamedLock
17//              Purpose: A global named lock, implemented as a lock file in file system
18//              Created: 2003/08/28
19//
20// --------------------------------------------------------------------------
21class NamedLock
22{
23public:
24        NamedLock();
25        ~NamedLock();
26private:
27        // No copying allowed
28        NamedLock(const NamedLock &);
29
30public:
31        bool TryAndGetLock(const std::string& rFilename, int mode = 0755);
32        bool GotLock() {return mFileDescriptor != -1;}
33        void ReleaseLock();
34       
35       
36private:
37        int mFileDescriptor;
38};
39
40#endif // NAMEDLOCK__H
41
Note: See TracBrowser for help on using the repository browser.