blob: 4fcf70ff09a1d85fe37f5b163147a54636a3e8f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright 2005-2017 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef MUMBLE_MUMBLE_LOCKFILE_H_
#define MUMBLE_MUMBLE_LOCKFILE_H_
#if defined(Q_OS_WIN)
# include <windows.h>
#endif
/// UserLockFile implements an atomic lock file
/// that can be used as a mutex between different
/// processes run by the same user.
class UserLockFile {
#if defined(Q_OS_WIN)
HANDLE m_handle;
#endif
QString m_path;
public:
/// Constructs a LockFile at path.
/// The path should be somewhere
/// owned by the current user, such
/// as inside the home directory of
/// the user. This is to avoid clashing
/// with other lock files.
UserLockFile(const QString &path);
/// Destroys the LockFile, and ensures
/// that it is released.
~UserLockFile();
/// Returns the path that the lock file
/// exists at.
QString path() const;
/// Acquires the lock file.
bool acquire();
/// Releases the lock file.
void release();
};
#endif
|