Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qlockfile.h
Go to the documentation of this file.
1// Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QLOCKFILE_H
5#define QLOCKFILE_H
6
7#include <QtCore/qstring.h>
8#include <QtCore/qscopedpointer.h>
9
10#include <chrono>
11
13
15
16class Q_CORE_EXPORT QLockFile
17{
18public:
20 ~QLockFile();
21
22 QString fileName() const;
23
24 bool lock();
25 bool tryLock(int timeout);
26 void unlock();
27
28 void setStaleLockTime(int);
29 int staleLockTime() const;
30
31 bool tryLock(std::chrono::milliseconds timeout = std::chrono::milliseconds::zero());
32
33 void setStaleLockTime(std::chrono::milliseconds value);
34 std::chrono::milliseconds staleLockTimeAsDuration() const;
35
36 bool isLocked() const;
37 bool getLockInfo(qint64 *pid, QString *hostname, QString *appname) const;
38 bool removeStaleLockFile();
39
40 enum LockError {
42 LockFailedError = 1,
43 PermissionError = 2,
44 UnknownError = 3
45 };
46 LockError error() const;
47
48protected:
49 QScopedPointer<QLockFilePrivate> d_ptr;
50
51private:
52 Q_DECLARE_PRIVATE(QLockFile)
53 Q_DISABLE_COPY(QLockFile)
54};
55
57
58#endif // QLOCKFILE_H
\inmodule QtCore
Definition qlockfile.h:17
QScopedPointer< QLockFilePrivate > d_ptr
Definition qlockfile.h:49
LockError
This enum describes the result of the last call to lock() or tryLock().
Definition qlockfile.h:40
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLbitfield GLuint64 timeout
[4]
@ NoError
Definition main.cpp:34
long long qint64
Definition qtypes.h:60
mutex tryLock(deadline.remainingTime())
[4]
QReadWriteLock lock
[0]
mutex unlock()