代码拉取完成,页面将自动刷新
#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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。