mirror of https://github.com/AxioDL/metaforce.git
General: Make use of lock deduction guides
This commit is contained in:
parent
dca87e7dce
commit
1d0151ccbc
|
@ -991,7 +991,7 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc
|
||||||
/* Classify intermediate into tag */
|
/* Classify intermediate into tag */
|
||||||
urde::SObjectTag pathTag = buildTagFromPath(path);
|
urde::SObjectTag pathTag = buildTagFromPath(path);
|
||||||
if (pathTag) {
|
if (pathTag) {
|
||||||
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
|
std::unique_lock lk{m_backgroundIndexMutex};
|
||||||
bool useGlob = false;
|
bool useGlob = false;
|
||||||
|
|
||||||
/* Special multi-resource intermediates */
|
/* Special multi-resource intermediates */
|
||||||
|
|
|
@ -23,12 +23,12 @@ public:
|
||||||
|
|
||||||
void WaitUntilComplete() override {
|
void WaitUntilComplete() override {
|
||||||
while (!m_complete.load() && !m_cancel.load()) {
|
while (!m_complete.load() && !m_cancel.load()) {
|
||||||
std::unique_lock<std::mutex> lk(CDvdFile::m_WaitMutex);
|
std::unique_lock lk{CDvdFile::m_WaitMutex};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool IsComplete() override { return m_complete.load(); }
|
bool IsComplete() override { return m_complete.load(); }
|
||||||
void PostCancelRequest() override {
|
void PostCancelRequest() override {
|
||||||
std::unique_lock<std::mutex> waitlk(CDvdFile::m_WaitMutex);
|
std::unique_lock waitlk{CDvdFile::m_WaitMutex};
|
||||||
m_cancel.store(true);
|
m_cancel.store(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,15 +61,16 @@ std::condition_variable CDvdFile::m_WorkerCV;
|
||||||
std::mutex CDvdFile::m_WaitMutex;
|
std::mutex CDvdFile::m_WaitMutex;
|
||||||
std::atomic_bool CDvdFile::m_WorkerRun = {false};
|
std::atomic_bool CDvdFile::m_WorkerRun = {false};
|
||||||
std::vector<std::shared_ptr<IDvdRequest>> CDvdFile::m_RequestQueue;
|
std::vector<std::shared_ptr<IDvdRequest>> CDvdFile::m_RequestQueue;
|
||||||
|
|
||||||
void CDvdFile::WorkerProc() {
|
void CDvdFile::WorkerProc() {
|
||||||
logvisor::RegisterThreadName("CDvdFile");
|
logvisor::RegisterThreadName("CDvdFile");
|
||||||
while (m_WorkerRun.load()) {
|
while (m_WorkerRun.load()) {
|
||||||
std::unique_lock<std::mutex> lk(CDvdFile::m_WorkerMutex);
|
std::unique_lock lk{m_WorkerMutex};
|
||||||
while (!CDvdFile::m_RequestQueue.empty()) {
|
while (!m_RequestQueue.empty()) {
|
||||||
std::vector<std::shared_ptr<IDvdRequest>> swapQueue;
|
std::vector<std::shared_ptr<IDvdRequest>> swapQueue;
|
||||||
swapQueue.swap(CDvdFile::m_RequestQueue);
|
swapQueue.swap(m_RequestQueue);
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
std::unique_lock<std::mutex> waitlk(CDvdFile::m_WaitMutex);
|
std::unique_lock waitlk{m_WaitMutex};
|
||||||
for (std::shared_ptr<IDvdRequest>& req : swapQueue) {
|
for (std::shared_ptr<IDvdRequest>& req : swapQueue) {
|
||||||
auto& concreteReq = static_cast<CFileDvdRequest&>(*req);
|
auto& concreteReq = static_cast<CFileDvdRequest&>(*req);
|
||||||
concreteReq.DoRequest();
|
concreteReq.DoRequest();
|
||||||
|
@ -88,7 +89,7 @@ void CDvdFile::WorkerProc() {
|
||||||
std::shared_ptr<IDvdRequest> CDvdFile::AsyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int off,
|
std::shared_ptr<IDvdRequest> CDvdFile::AsyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int off,
|
||||||
std::function<void(u32)>&& cb) {
|
std::function<void(u32)>&& cb) {
|
||||||
std::shared_ptr<IDvdRequest> ret = std::make_shared<CFileDvdRequest>(*this, buf, len, whence, off, std::move(cb));
|
std::shared_ptr<IDvdRequest> ret = std::make_shared<CFileDvdRequest>(*this, buf, len, whence, off, std::move(cb));
|
||||||
std::unique_lock<std::mutex> lk(CDvdFile::m_WorkerMutex);
|
std::unique_lock lk{m_WorkerMutex};
|
||||||
m_RequestQueue.emplace_back(ret);
|
m_RequestQueue.emplace_back(ret);
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
m_WorkerCV.notify_one();
|
m_WorkerCV.notify_one();
|
||||||
|
|
|
@ -93,21 +93,21 @@ public:
|
||||||
}
|
}
|
||||||
void controllerDisconnected(unsigned idx) override {
|
void controllerDisconnected(unsigned idx) override {
|
||||||
/* Controller thread */
|
/* Controller thread */
|
||||||
std::unique_lock<std::mutex> lk(m_stateLock);
|
std::unique_lock lk{m_stateLock};
|
||||||
m_statusChanges[idx].store(EStatusChange::Disconnected);
|
m_statusChanges[idx].store(EStatusChange::Disconnected);
|
||||||
m_states[idx].reset();
|
m_states[idx].reset();
|
||||||
}
|
}
|
||||||
void controllerUpdate(unsigned idx, boo::EDolphinControllerType,
|
void controllerUpdate(unsigned idx, boo::EDolphinControllerType,
|
||||||
const boo::DolphinControllerState& state) override {
|
const boo::DolphinControllerState& state) override {
|
||||||
/* Controller thread */
|
/* Controller thread */
|
||||||
std::unique_lock<std::mutex> lk(m_stateLock);
|
std::unique_lock lk{m_stateLock};
|
||||||
m_states[idx] = state;
|
m_states[idx] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<CFinalInput, 4> m_lastUpdates;
|
std::array<CFinalInput, 4> m_lastUpdates;
|
||||||
const CFinalInput& getFinalInput(unsigned idx, float dt, float leftDiv, float rightDiv) {
|
const CFinalInput& getFinalInput(unsigned idx, float dt, float leftDiv, float rightDiv) {
|
||||||
/* Game thread */
|
/* Game thread */
|
||||||
std::unique_lock<std::mutex> lk(m_stateLock);
|
std::unique_lock lk{m_stateLock};
|
||||||
boo::DolphinControllerState state = m_states[idx];
|
boo::DolphinControllerState state = m_states[idx];
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
state.clamp(); /* PADClamp equivalent */
|
state.clamp(); /* PADClamp equivalent */
|
||||||
|
|
Loading…
Reference in New Issue