Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QLOCKFILE_H
6
#
define
QLOCKFILE_H
7
8
#
include
<
QtCore
/
qstring
.
h
>
9
#
include
<
QtCore
/
qscopedpointer
.
h
>
10
11
#
include
<
chrono
>
12
#
include
<
memory
>
13
14
QT_BEGIN_NAMESPACE
15
16
class
QLockFilePrivate;
17
18
class
Q_CORE_EXPORT
QLockFile
19
{
20
public
:
21
explicit
QLockFile(
const
QString &fileName);
22
~QLockFile();
23
24
QString fileName()
const
;
25
26
bool
lock();
27
QT_CORE_INLINE_SINCE(6, 10)
28
bool
tryLock(
int
timeout);
29
void
unlock();
30
31
QT_CORE_INLINE_SINCE(6, 10)
32
void
setStaleLockTime(
int
);
33
QT_CORE_INLINE_SINCE(6, 10)
34
int
staleLockTime()
const
;
35
36
bool
tryLock(std::chrono::milliseconds timeout = std::chrono::milliseconds::zero());
37
38
void
setStaleLockTime(std::chrono::milliseconds value);
39
std::chrono::milliseconds staleLockTimeAsDuration()
const
;
40
41
bool
isLocked()
const
;
42
bool
getLockInfo(qint64 *pid, QString *hostname, QString *appname)
const
;
43
bool
removeStaleLockFile();
44
45
enum
LockError {
46
NoError = 0,
47
LockFailedError = 1,
48
PermissionError = 2,
49
UnknownError = 3
50
};
51
LockError error()
const
;
52
53
private
:
54
std::unique_ptr<QLockFilePrivate> d_ptr;
55
56
Q_DECLARE_PRIVATE(QLockFile)
57
Q_DISABLE_COPY(QLockFile)
58
};
59
60
#
if
QT_CORE_INLINE_IMPL_SINCE
(
6
,
10
)
61
bool
QLockFile::tryLock(
int
timeout)
62
{
63
return
tryLock(std::chrono::milliseconds{timeout});
64
}
65
66
void
QLockFile::setStaleLockTime(
int
staleLockTime)
67
{
68
setStaleLockTime(std::chrono::milliseconds{staleLockTime});
69
}
70
71
int
QLockFile::staleLockTime()
const
72
{
73
return
int
(staleLockTimeAsDuration().count());
74
}
75
#
endif
// QT_CORE_INLINE_IMPL_SINCE(6, 10)
76
77
QT_END_NAMESPACE
78
79
#
endif
// QLOCKFILE_H
QLockFile
\inmodule QtCore
Definition
qlockfile.h:19
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
getLockInfo
static std::optional< QLockFilePrivate::LockFileInfo > getLockInfo(int fd)
Definition
qlockfile.cpp:514
machineName
static QString machineName()
Definition
qlockfile.cpp:30
qtbase
src
corelib
io
qlockfile.h
Generated on
for Qt by
1.18.0