57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
|
#ifndef GLABELBACKUPINFO_H
|
||
|
#define GLABELBACKUPINFO_H
|
||
|
|
||
|
#include "../common/singleton.h"
|
||
|
#include "../common/spinlock_mutex.h"
|
||
|
|
||
|
class GlobelBackupInfo : public Singleton<GlobelBackupInfo> {
|
||
|
public:
|
||
|
GlobelBackupInfo(token) {}
|
||
|
~GlobelBackupInfo() {}
|
||
|
|
||
|
// 设置是否正在进行备份、还原等操作
|
||
|
void setIsBusy(bool isBusy) {
|
||
|
std::lock_guard<spinlock_mutex> lock(m_interMutex);
|
||
|
m_isBusy = isBusy;
|
||
|
}
|
||
|
|
||
|
// 是否正在进行备份、还原等操作
|
||
|
bool isBusy() {
|
||
|
std::lock_guard<spinlock_mutex> lock(m_interMutex);
|
||
|
return m_isBusy;
|
||
|
}
|
||
|
|
||
|
// 是否有备份分区
|
||
|
void setHasBackupPartition(bool has) {
|
||
|
m_hasBackupPartition = has;
|
||
|
}
|
||
|
|
||
|
// 是否有备份分区
|
||
|
bool hasBackupPartition() {
|
||
|
return m_hasBackupPartition;
|
||
|
}
|
||
|
|
||
|
void lock() {
|
||
|
m_outerMutex.lock();
|
||
|
}
|
||
|
|
||
|
void unlock() {
|
||
|
m_outerMutex.unlock();
|
||
|
}
|
||
|
|
||
|
bool try_lock() {
|
||
|
return m_outerMutex.try_lock();
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
// 是否正在进行备份、还原等操作
|
||
|
bool m_isBusy = false;
|
||
|
// 是否有备份分区
|
||
|
bool m_hasBackupPartition = true;
|
||
|
|
||
|
spinlock_mutex m_interMutex;
|
||
|
spinlock_mutex m_outerMutex;
|
||
|
};
|
||
|
|
||
|
#endif // GLABELBACKUPINFO_H
|