summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-08-20 13:15:12 +0200
committerLéo Lam <leo@leolam.fr>2020-08-20 18:25:47 +0200
commitafde5b27753162e187cffc6ec765099bd0767459 (patch)
tree88b6ed4fb1ab57d556b653840b6969eb987d9d8e /src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp
parentf92ab2f5598789d9531bfe93e9abcc3dc4cc938d (diff)
ksys/act: Implement BaseProcLink
Diffstat (limited to 'src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp')
-rw-r--r--src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp b/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp
deleted file mode 100644
index 8479ae09..00000000
--- a/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "KingSystem/ActorSystem/actBaseProcLinkDataMgr.h"
-#include <prim/seadScopedLock.h>
-#include <thread/seadThread.h>
-#include "KingSystem/ActorSystem/actBaseProc.h"
-#include "KingSystem/ActorSystem/actBaseProcMgr.h"
-
-namespace ksys::act {
-
-SEAD_SINGLETON_DISPOSER_IMPL(BaseProcLinkDataMgr)
-
-BaseProc* BaseProcLinkData::getProc(u32 id, bool allow_deleted) const {
- if (id == u32(-1) || mId != id)
- return nullptr;
-
- if (!allow_deleted && mProc && mProc->getState() == BaseProc::State::Delete)
- return nullptr;
-
- return mProc;
-}
-
-sead::CriticalSection* BaseProcLinkData::lockIfNeeded() {
- if (BaseProcMgr::instance()->isHighPriorityThread())
- return nullptr;
-
- mCS.lock();
- return &mCS;
-}
-
-bool BaseProcLinkDataMgr::acquireLink(BaseProc* proc) {
- auto lock = sead::makeScopedLock(mCS);
- s32 index = mIndex;
- for (s32 i = 0; i < mData.size(); ++i) {
- const s32 j = index == 0x800 ? 0 : index;
- auto& data = mData[j];
- if (data.mId == u32(-1)) {
- {
- auto data_lock = sead::makeScopedLock(data.mCS);
- data.mProc = proc;
- data.mId = proc->mId;
- proc->mBaseProcLinkData = &data;
- }
- mIndex = j + 1;
- return true;
- }
- index = j + 1;
- }
-
- for (s32 i = 0; i < mData.size(); ++i) {
- auto data_lock = sead::makeScopedLock(mData[i].mCS);
- // Debug code was probably here?
- }
-
- return false;
-}
-
-bool BaseProcLinkDataMgr::releaseLink(BaseProc* proc) {
- auto* data = proc->mBaseProcLinkData;
- if (!data)
- return false;
-
- const auto thread = sead::ThreadMgr::instance()->getCurrentThread();
- thread->getPriority();
-
- auto lock = sead::makeScopedLock(data->mCS);
- data->mProc = nullptr;
- data->mId = -1;
- proc->mBaseProcLinkData = nullptr;
- return true;
-}
-
-} // namespace ksys::act