1 Star 2 Fork 0

InnovatorNZ/CppGCPtr

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
GCPhase.h 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
#ifndef CPPGCPTR_GCPHASE_H
#define CPPGCPTR_GCPHASE_H
#include <iostream>
#include <string>
#include <atomic>
#include <memory>
#include "PhaseEnum.h"
#include "SpinReadWriteLock.h"
#include "MutexReadWriteLock.h"
#include "WeakSpinReadWriteLock.h"
#include "SpinLock.h"
#define USE_SPINLOCK 0
class GCPhase {
private:
static std::atomic<eGCPhase> gcPhase;
static std::atomic<MarkState> currentMarkState;
static IReadWriteLock* stwLock;
static IReadWriteLock* gcPhaseLock;
public:
static eGCPhase getGCPhase();
static std::string getGCPhaseString();
static MarkState getCurrentMarkState() {
return currentMarkState;
}
static MarkStateBit getCurrentMarkStateBit();
static void SwitchToNextPhase();
static bool needSweep(MarkState markState);
static bool needSweep(MarkStateBit markState);
static bool needSelfHeal(MarkState markState);
static bool isLiveObject(MarkStateBit);
static bool isLiveObject(MarkState);
static bool duringGC() {
return gcPhase != eGCPhase::NONE;
}
static bool duringMarking() {
return gcPhase == eGCPhase::CONCURRENT_MARK || gcPhase == eGCPhase::REMARK;
}
static bool duringMarking(const eGCPhase& gcPhase) {
return gcPhase == eGCPhase::CONCURRENT_MARK || gcPhase == eGCPhase::REMARK;
}
static void EnterCriticalSection() {
stwLock->lockRead();
}
static void LeaveCriticalSection() {
stwLock->unlockRead();
}
static IReadWriteLock* getSTWLock() {
return stwLock;
}
class RAIISTWLock {
private:
bool owns;
public:
RAIISTWLock();
explicit RAIISTWLock(bool doNotLockAtRemarkPhase);
~RAIISTWLock();
};
};
#endif //CPPGCPTR_GCPHASE_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/innovatornz/CppGCPtr.git
git@gitee.com:innovatornz/CppGCPtr.git
innovatornz
CppGCPtr
CppGCPtr
master

搜索帮助