TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttklockedfile.h
Go to the documentation of this file.
1 #ifndef TTKLOCKEDFILE_H
2 #define TTKLOCKEDFILE_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QFile>
23 #ifdef Q_OS_WIN
24 #include <QVector>
25 #endif
26 #include "ttkmoduleexport.h"
27 
31 namespace TTKLockedPrivate {
35  class TTK_MODULE_EXPORT TTKLockedFile : public QFile
36  {
37  public:
38  enum LockMode
39  {
40  NoLock = 0,
42  WriteLock
43  };
44 
48  TTKLockedFile();
49  explicit TTKLockedFile(const QString &name);
53  ~TTKLockedFile();
54 
55  bool open(OpenMode mode);
60  bool lock(LockMode mode, bool block = true);
64  bool unlock();
68  bool isLocked() const;
72  LockMode lockMode() const;
77  private:
78  #ifdef Q_OS_WIN
79  Qt::HANDLE m_wmutex;
80  Qt::HANDLE m_rmutex;
81  QVector<Qt::HANDLE> m_rmutexes;
82  QString m_mutexname;
83 
84  Qt::HANDLE getMutexHandle(int idx, bool doCreate);
85  bool waitMutex(Qt::HANDLE mutex, bool doBlock);
86 
87  #endif
89  };
90 }
91 
92 #endif //TTKLOCKEDFILE_H
#define TTK_MODULE_EXPORT
The namespace of locked private.
The class of the ttk local file.
Definition: ttklockedfile.h:35
const char * name
Definition: http_parser.c:458
const char int mode
Definition: ioapi.h:135