mirror of
https://github.com/zeldaret/botw
synced 2026-08-19 21:42:01 -04:00
Switch to subrepos
git subrepo clone https://github.com/open-ead/sead lib/sead subrepo: subdir: "lib/sead" merged: "1b66e825d" upstream: origin: "https://github.com/open-ead/sead" branch: "master" commit: "1b66e825d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" git subrepo clone (merge) https://github.com/open-ead/nnheaders lib/NintendoSDK subrepo: subdir: "lib/NintendoSDK" merged: "9ee21399f" upstream: origin: "https://github.com/open-ead/nnheaders" branch: "master" commit: "9ee21399f" git-subrepo: version: "0.4.3" origin: "ssh://git@github.com/ingydotnet/git-subrepo" commit: "2f68596" git subrepo clone https://github.com/open-ead/agl lib/agl subrepo: subdir: "lib/agl" merged: "7c063271b" upstream: origin: "https://github.com/open-ead/agl" branch: "master" commit: "7c063271b" git-subrepo: version: "0.4.3" origin: "ssh://git@github.com/ingydotnet/git-subrepo" commit: "2f68596" git subrepo clone https://github.com/open-ead/EventFlow lib/EventFlow subrepo: subdir: "lib/EventFlow" merged: "c35d21b34" upstream: origin: "https://github.com/open-ead/EventFlow" branch: "master" commit: "c35d21b34" git-subrepo: version: "0.4.3" origin: "ssh://git@github.com/ingydotnet/git-subrepo" commit: "2f68596"
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "framework/seadMethodTree.h"
|
||||
#include "framework/seadTaskBase.h"
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class CalculateTask : public TaskBase
|
||||
{
|
||||
SEAD_RTTI_OVERRIDE(CalculateTask, TaskBase)
|
||||
public:
|
||||
explicit CalculateTask(const TaskConstructArg& arg);
|
||||
CalculateTask(const TaskConstructArg& arg, const char* name);
|
||||
~CalculateTask() override;
|
||||
void pauseCalc(bool b) override;
|
||||
void pauseDraw(bool b) override;
|
||||
void pauseCalcRec(bool b) override;
|
||||
void pauseDrawRec(bool b) override;
|
||||
void pauseCalcChild(bool b) override;
|
||||
void pauseDrawChild(bool b) override;
|
||||
void attachCalcImpl() override;
|
||||
void attachDrawImpl() override;
|
||||
void detachCalcImpl() override;
|
||||
void detachDrawImpl() override;
|
||||
const RuntimeTypeInfo::Interface* getCorrespondingMethodTreeMgrTypeInfo() const override;
|
||||
MethodTreeNode* getMethodTreeNode(s32 method_type) override;
|
||||
virtual void calc() {}
|
||||
|
||||
protected:
|
||||
MethodTreeNode mCalcNode{nullptr};
|
||||
};
|
||||
} // namespace sead
|
||||
@@ -0,0 +1,91 @@
|
||||
#ifndef SEAD_FRAMEWORK_H_
|
||||
#define SEAD_FRAMEWORK_H_
|
||||
|
||||
//#include <framework/seadMethodTreeMgr.h>
|
||||
#include <framework/seadTaskBase.h>
|
||||
//#include <framework/seadTaskMgr.h>
|
||||
//#include <gfx/seadFrameBuffer.h>
|
||||
//#include <heap/seadArena.h>
|
||||
//#include <heap/seadHeap.h>
|
||||
#include <hostio/seadHostIOMgr.h>
|
||||
#include <prim/seadDelegateEventSlot.h>
|
||||
#include <prim/seadRuntimeTypeInfo.h>
|
||||
#include <time/seadTickSpan.h>
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class Arena;
|
||||
|
||||
class FrameBuffer;
|
||||
class Heap;
|
||||
class LogicalFrameBuffer;
|
||||
class MethodTreeMgr;
|
||||
class TaskMgr;
|
||||
|
||||
class Framework
|
||||
{
|
||||
SEAD_RTTI_BASE(Framework)
|
||||
|
||||
public:
|
||||
struct CreateSystemTaskArg
|
||||
{
|
||||
inline CreateSystemTaskArg();
|
||||
|
||||
HostIOMgr::Parameter* hostio_parameter;
|
||||
TickSpan infloop_detection_span;
|
||||
};
|
||||
|
||||
struct InitializeArg
|
||||
{
|
||||
InitializeArg();
|
||||
|
||||
u32 heap_size;
|
||||
Arena* arena;
|
||||
};
|
||||
|
||||
struct RunArg
|
||||
{
|
||||
RunArg();
|
||||
|
||||
u32 prepare_stack_size;
|
||||
s32 prepare_priority;
|
||||
};
|
||||
|
||||
enum ProcessPriority
|
||||
{
|
||||
cProcessPriority_Idle = 0,
|
||||
cProcessPriority_Normal = 1,
|
||||
cProcessPriority_High = 2,
|
||||
cProcessPriority_RealTime = 3
|
||||
};
|
||||
|
||||
public:
|
||||
Framework();
|
||||
virtual ~Framework();
|
||||
|
||||
virtual void run(Heap*, const TaskBase::CreateArg&, const RunArg&);
|
||||
virtual void createSystemTasks(TaskBase*, const CreateSystemTaskArg&);
|
||||
virtual FrameBuffer* getMethodFrameBuffer(s32) const = 0;
|
||||
virtual LogicalFrameBuffer* getMethodLogicalFrameBuffer(s32) const;
|
||||
virtual bool setProcessPriority(ProcessPriority);
|
||||
virtual void reserveReset(void*);
|
||||
virtual void initRun_(Heap*);
|
||||
virtual void runImpl_();
|
||||
virtual MethodTreeMgr* createMethodTreeMgr_(Heap*) = 0;
|
||||
virtual void procReset_();
|
||||
|
||||
MethodTreeMgr* getMethodTreeMgr() const { return mMethodTreeMgr; }
|
||||
|
||||
typedef DelegateEvent<void*> ResetEvent;
|
||||
|
||||
bool mReserveReset;
|
||||
void* mResetParameter;
|
||||
ResetEvent mResetEvent;
|
||||
TaskMgr* mTaskMgr;
|
||||
MethodTreeMgr* mMethodTreeMgr;
|
||||
Heap* mMethodTreeMgrHeap;
|
||||
};
|
||||
|
||||
} // namespace sead
|
||||
|
||||
#endif // SEAD_FRAMEWORK_H_
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef SEAD_HEAP_POLICIES_H_
|
||||
#define SEAD_HEAP_POLICIES_H_
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <heap/seadHeapMgr.h>
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class Heap;
|
||||
|
||||
class HeapArray
|
||||
{
|
||||
public:
|
||||
Heap* getHeap(s32 index) const
|
||||
{
|
||||
if (index < HeapMgr::getRootHeapNum())
|
||||
return mHeaps[index];
|
||||
return mHeaps[0];
|
||||
}
|
||||
|
||||
Heap* getPrimaryHeap() const { return mHeaps[mPrimaryIndex]; }
|
||||
|
||||
Heap* mHeaps[4];
|
||||
bool mAdjusted[4]{};
|
||||
s32 mPrimaryIndex{};
|
||||
};
|
||||
|
||||
struct HeapPolicy
|
||||
{
|
||||
Heap* parent{};
|
||||
u32 size{};
|
||||
u32 create_slack{};
|
||||
u32 adjust_slack{};
|
||||
u8 adjust{};
|
||||
u8 temporary{};
|
||||
u8 dont_create{};
|
||||
};
|
||||
|
||||
struct HeapPolicies
|
||||
{
|
||||
HeapPolicy mPolicies[4];
|
||||
s32 mPrimaryIndex{};
|
||||
};
|
||||
|
||||
} // namespace sead
|
||||
|
||||
#endif // SEAD_HEAP_POLICIES_H_
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "basis/seadTypes.h"
|
||||
#include "framework/seadCalculateTask.h"
|
||||
#include "framework/seadTaskMgr.h"
|
||||
#include "thread/seadAtomic.h"
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class InfLoopChecker : public CalculateTask
|
||||
{
|
||||
SEAD_TASK_SINGLETON(InfLoopChecker)
|
||||
SEAD_RTTI_OVERRIDE(InfLoopChecker, CalculateTask)
|
||||
|
||||
public:
|
||||
struct InfLoopParam
|
||||
{
|
||||
};
|
||||
|
||||
using InfLoopEvent = DelegateEvent<const InfLoopParam&>;
|
||||
|
||||
explicit InfLoopChecker(const TaskConstructArg& arg);
|
||||
~InfLoopChecker() override;
|
||||
|
||||
void countUp();
|
||||
void prepare() override;
|
||||
void calc() override;
|
||||
|
||||
InfLoopEvent& getEvent() { return mEvent; }
|
||||
|
||||
private:
|
||||
void onInfLoop_();
|
||||
|
||||
u32 mLoopCount;
|
||||
u32 mLoopThreshold;
|
||||
bool mEnabled;
|
||||
InfLoopEvent mEvent;
|
||||
sead::Atomic<u32> mSkipCounter;
|
||||
};
|
||||
} // namespace sead
|
||||
@@ -0,0 +1,88 @@
|
||||
#ifndef SEAD_METHODTREE_H_
|
||||
#define SEAD_METHODTREE_H_
|
||||
|
||||
#include <container/seadTreeNode.h>
|
||||
#include <heap/seadDisposer.h>
|
||||
#include <prim/seadBitFlag.h>
|
||||
#include <prim/seadDelegate.h>
|
||||
#include <prim/seadNamable.h>
|
||||
#include <prim/seadRuntimeTypeInfo.h>
|
||||
#include <prim/seadStorageFor.h>
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class CriticalSection;
|
||||
|
||||
template <typename T, typename U>
|
||||
class IDelegate2;
|
||||
|
||||
class MethodTreeNode : public IDisposer, public TTreeNode<MethodTreeNode*>, public INamable
|
||||
{
|
||||
SEAD_RTTI_BASE(MethodTreeNode)
|
||||
|
||||
public:
|
||||
enum PauseFlag
|
||||
{
|
||||
cPause_None = 0,
|
||||
cPause_Self = 1,
|
||||
cPause_Child = 2,
|
||||
cPause_Both = 3,
|
||||
};
|
||||
|
||||
using PauseEventDelegate = IDelegate2<MethodTreeNode*, PauseFlag>;
|
||||
|
||||
// NON_MATCHING: stores for mPauseFlag, mPauseEventDelegate, mUserID
|
||||
explicit MethodTreeNode(CriticalSection* cs) : TTreeNode(this)
|
||||
{
|
||||
mCriticalSection = cs;
|
||||
mPauseEventDelegate = nullptr;
|
||||
mUserID = nullptr;
|
||||
mDelegateHolder.construct(sead::Delegate<MethodTreeNode>());
|
||||
setPauseFlag(cPause_Both);
|
||||
}
|
||||
|
||||
~MethodTreeNode() override { detachAll(); }
|
||||
|
||||
template <typename Delegate>
|
||||
void bind(const Delegate& delegate, const char* name)
|
||||
{
|
||||
lock_();
|
||||
mDelegateHolder.construct(delegate);
|
||||
unlock_();
|
||||
|
||||
if (name)
|
||||
setName(name);
|
||||
}
|
||||
|
||||
void call();
|
||||
void detachAll();
|
||||
void pushBackChild(MethodTreeNode* node);
|
||||
void pushFrontChild(MethodTreeNode* node);
|
||||
|
||||
void setPauseFlag(PauseFlag flag)
|
||||
{
|
||||
lock_();
|
||||
if (mPauseEventDelegate)
|
||||
mPauseEventDelegate->invoke(this, flag);
|
||||
mPauseFlag = flag;
|
||||
unlock_();
|
||||
}
|
||||
|
||||
private:
|
||||
void attachMutexRec_(CriticalSection* m) const;
|
||||
void callRec_();
|
||||
|
||||
void lock_();
|
||||
void unlock_();
|
||||
|
||||
StorageFor<sead::AnyDelegate> mDelegateHolder;
|
||||
mutable CriticalSection* mCriticalSection;
|
||||
[[maybe_unused]] u32 mPriority;
|
||||
BitFlag32 mPauseFlag;
|
||||
PauseEventDelegate* mPauseEventDelegate;
|
||||
void* mUserID;
|
||||
};
|
||||
|
||||
} // namespace sead
|
||||
|
||||
#endif // SEAD_METHODTREE_H_
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef SEAD_METHODTREEMGR_H_
|
||||
#define SEAD_METHODTREEMGR_H_
|
||||
|
||||
//#include <framework/seadMethodTree.h>
|
||||
#include <prim/seadRuntimeTypeInfo.h>
|
||||
#include <thread/seadCriticalSection.h>
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class MethodTreeNode;
|
||||
|
||||
class MethodTreeMgr
|
||||
{
|
||||
SEAD_RTTI_BASE(MethodTreeMgr)
|
||||
|
||||
public:
|
||||
MethodTreeMgr();
|
||||
virtual ~MethodTreeMgr();
|
||||
|
||||
virtual void attachMethod(s32, MethodTreeNode*) = 0;
|
||||
virtual MethodTreeNode* getRootMethodTreeNode(s32) = 0;
|
||||
virtual void pauseAll(bool) = 0;
|
||||
virtual void pauseAppCalc(bool) = 0;
|
||||
|
||||
CriticalSection mCS;
|
||||
};
|
||||
|
||||
} // namespace sead
|
||||
|
||||
#endif // SEAD_METHODTREEMGR_H_
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "heap/seadDisposer.h"
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class ProcessMeterBarBase;
|
||||
|
||||
// FIXME
|
||||
class ProcessMeter
|
||||
{
|
||||
SEAD_SINGLETON_DISPOSER(ProcessMeter)
|
||||
ProcessMeter() = default;
|
||||
|
||||
public:
|
||||
void attachProcessMeterBar(ProcessMeterBarBase* bar);
|
||||
void detachProcessMeterBar(ProcessMeterBarBase* bar);
|
||||
};
|
||||
} // namespace sead
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include "container/seadBuffer.h"
|
||||
#include "container/seadSafeArray.h"
|
||||
#include "gfx/seadColor.h"
|
||||
#include "heap/seadDisposer.h"
|
||||
#include "prim/seadNamable.h"
|
||||
#include "prim/seadSafeString.h"
|
||||
#include "time/seadTickTime.h"
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class ProcessMeter;
|
||||
|
||||
class ProcessMeterBarBase : public IDisposer, public INamable
|
||||
{
|
||||
public:
|
||||
struct Section
|
||||
{
|
||||
TickTime time;
|
||||
TickSpan span;
|
||||
Color4f color;
|
||||
s32 parent;
|
||||
};
|
||||
|
||||
ProcessMeterBarBase(Section* sections, s32 num_sections, const SafeString& name,
|
||||
const Color4f& color);
|
||||
~ProcessMeterBarBase() override;
|
||||
|
||||
void measureBegin();
|
||||
void measureBegin(const TickTime& start_time);
|
||||
void measureBegin(const Color4f& color);
|
||||
void measureBegin(const TickTime& start_time, const Color4f& color);
|
||||
|
||||
void measureEnd();
|
||||
void measureEnd(const TickTime& end_time);
|
||||
|
||||
const Section* getLastFirstBegin() const;
|
||||
TickSpan getLastTotalSpan() const;
|
||||
|
||||
void onEndFrame();
|
||||
|
||||
ProcessMeter* getParentProcessMeter() const { return mParent; }
|
||||
void setParentProcessMeter(ProcessMeter* parent);
|
||||
|
||||
void setColor(const Color4f& color) { mColor = color; }
|
||||
|
||||
protected:
|
||||
void measureBeginImpl_(const TickTime& start_time, Color4f color);
|
||||
void measureEndImpl_(const TickTime& end_time);
|
||||
|
||||
void addSection_(const TickTime& time, Color4f color, s32 parent);
|
||||
Section* getCurSection_(s32 idx);
|
||||
void endSection_(s32 idx, const TickTime& time);
|
||||
|
||||
void* _30 = nullptr;
|
||||
void* _38 = nullptr;
|
||||
ProcessMeter* mParent = nullptr;
|
||||
Color4f mColor;
|
||||
SafeArray<Buffer<Section>, 2> mSectionList;
|
||||
SafeArray<TickTime, 2> mTicks;
|
||||
SafeArray<s32, 2> _88;
|
||||
s32 mActiveBufferIdx = 0;
|
||||
s32 mTopSection = -1;
|
||||
s32 mOverNum = 0;
|
||||
bool mEnabled = false;
|
||||
};
|
||||
|
||||
template <s32 N>
|
||||
class MultiProcessMeterBar : public ProcessMeterBarBase
|
||||
{
|
||||
public:
|
||||
MultiProcessMeterBar(const SafeString& name = SafeString::cEmptyString,
|
||||
const Color4f& color = Color4f::cRed)
|
||||
: ProcessMeterBarBase(mSections, N, name, color)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
Section mSections[2 * N];
|
||||
};
|
||||
} // namespace sead
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef SEAD_TASKBASE_H_
|
||||
#define SEAD_TASKBASE_H_
|
||||
|
||||
#include <container/seadTList.h>
|
||||
#include <container/seadTreeNode.h>
|
||||
#include <framework/seadHeapPolicies.h>
|
||||
#include <framework/seadTaskID.h>
|
||||
#include <heap/seadDisposer.h>
|
||||
#include <prim/seadBitFlag.h>
|
||||
#include <prim/seadDelegateEventSlot.h>
|
||||
#include <prim/seadNamable.h>
|
||||
#include <prim/seadRuntimeTypeInfo.h>
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class FaderTaskBase;
|
||||
class MethodTreeNode;
|
||||
class TaskEvent;
|
||||
class TaskMgr;
|
||||
class TaskParameter;
|
||||
|
||||
class TaskBase : public TTreeNode<TaskBase*>, public IDisposer, public INamable
|
||||
{
|
||||
SEAD_RTTI_BASE(TaskBase)
|
||||
|
||||
public:
|
||||
typedef TListNode<TaskBase*> ListNode;
|
||||
typedef TList<TaskBase*> List;
|
||||
|
||||
public:
|
||||
enum State
|
||||
{
|
||||
cCreated = 0,
|
||||
cPrepare = 1,
|
||||
cPrepareDone = 2,
|
||||
cSleep = 3,
|
||||
cRunning = 4,
|
||||
cDying = 5,
|
||||
cDestroyable = 6,
|
||||
cDead = 7
|
||||
};
|
||||
|
||||
enum Tag
|
||||
{
|
||||
cSystem = 0,
|
||||
cApp = 1
|
||||
};
|
||||
|
||||
struct CreateArg
|
||||
{
|
||||
typedef void (*SingletonFunc)(TaskBase*);
|
||||
|
||||
TaskClassID factory;
|
||||
HeapPolicies heap_policies;
|
||||
TaskBase* parent;
|
||||
TaskParameter* parameter;
|
||||
FaderTaskBase* fader;
|
||||
TaskBase* src_task;
|
||||
TaskBase** created_task;
|
||||
DelegateEvent<TaskBase*>::Slot* create_callback;
|
||||
TaskUserID user_id;
|
||||
Tag tag;
|
||||
SingletonFunc instance_cb;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit TaskBase(const TaskConstructArg& arg);
|
||||
TaskBase(const TaskConstructArg& arg, const char* name);
|
||||
virtual ~TaskBase();
|
||||
|
||||
virtual void pauseCalc(bool b) = 0;
|
||||
virtual void pauseDraw(bool b) = 0;
|
||||
virtual void pauseCalcRec(bool b) = 0;
|
||||
virtual void pauseDrawRec(bool b) = 0;
|
||||
virtual void pauseCalcChild(bool b);
|
||||
virtual void pauseDrawChild(bool b);
|
||||
|
||||
virtual void prepare();
|
||||
virtual void enterCommon();
|
||||
virtual void enter();
|
||||
virtual void exit();
|
||||
virtual void onEvent(const TaskEvent&);
|
||||
virtual void attachCalcImpl() = 0;
|
||||
virtual void attachDrawImpl() = 0;
|
||||
virtual void detachCalcImpl() = 0;
|
||||
virtual void detachDrawImpl() = 0;
|
||||
virtual const RuntimeTypeInfo::Interface* getCorrespondingMethodTreeMgrTypeInfo() const = 0;
|
||||
virtual MethodTreeNode* getMethodTreeNode(s32 method_type) = 0;
|
||||
virtual void onDestroy();
|
||||
|
||||
TaskParameter* mParameter;
|
||||
BitFlag32 mInternalFlag;
|
||||
ListNode mTaskListNode;
|
||||
HeapArray mHeapArray;
|
||||
TaskMgr* mTaskMgr;
|
||||
State mState;
|
||||
Tag mTag;
|
||||
TaskClassID mClassID;
|
||||
};
|
||||
|
||||
} // namespace sead
|
||||
|
||||
#endif // SEAD_TASKBASE_H_
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef SEAD_TASK_ID_H_
|
||||
#define SEAD_TASK_ID_H_
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class HeapArray;
|
||||
class TaskBase;
|
||||
class TaskMgr;
|
||||
class TaskParameter;
|
||||
|
||||
struct TaskConstructArg
|
||||
{
|
||||
TaskConstructArg() = default;
|
||||
|
||||
HeapArray* heap_array;
|
||||
TaskMgr* mgr;
|
||||
TaskParameter* param;
|
||||
};
|
||||
|
||||
typedef TaskBase* (*TaskFactory)(const TaskConstructArg&);
|
||||
|
||||
class TaskClassID
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
cInvalid = 0,
|
||||
cInt = 1,
|
||||
cFactory = 2,
|
||||
cString = 3
|
||||
};
|
||||
|
||||
public:
|
||||
Type mType;
|
||||
union
|
||||
{
|
||||
s32 mInt;
|
||||
TaskFactory mFactory;
|
||||
const char* mString;
|
||||
} mID;
|
||||
};
|
||||
|
||||
class TaskUserID
|
||||
{
|
||||
public:
|
||||
s32 mID;
|
||||
};
|
||||
|
||||
} // namespace sead
|
||||
|
||||
#endif // SEAD_TASK_ID_H_
|
||||
@@ -0,0 +1,125 @@
|
||||
#ifndef SEAD_TASKMGR_H_
|
||||
#define SEAD_TASKMGR_H_
|
||||
|
||||
#include <framework/seadHeapPolicies.h>
|
||||
#include <framework/seadMethodTree.h>
|
||||
#include <framework/seadTaskBase.h>
|
||||
#include <heap/seadHeapMgr.h>
|
||||
#include <thread/seadCriticalSection.h>
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class DelegateThread;
|
||||
class Framework;
|
||||
class Heap;
|
||||
class NullFaderTask;
|
||||
|
||||
class TaskMgr
|
||||
{
|
||||
public:
|
||||
struct InitializeArg
|
||||
{
|
||||
public:
|
||||
InitializeArg(const TaskBase::CreateArg& roottask_arg)
|
||||
: create_queue_size(0x20), prepare_stack_size(0x8000), prepare_priority(-1),
|
||||
roottask_create_arg(roottask_arg), heap(NULL), parent_framework(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
u32 create_queue_size;
|
||||
u32 prepare_stack_size;
|
||||
s32 prepare_priority;
|
||||
const TaskBase::CreateArg& roottask_create_arg;
|
||||
Heap* heap;
|
||||
Framework* parent_framework;
|
||||
};
|
||||
|
||||
class TaskCreateContextMgr;
|
||||
|
||||
public:
|
||||
TaskMgr(const InitializeArg& arg);
|
||||
|
||||
void appendToList_(TaskBase::List& ls, TaskBase* task);
|
||||
bool changeTaskState_(TaskBase* task, TaskBase::State state);
|
||||
void destroyTaskSync(TaskBase* task);
|
||||
void doDestroyTask_(TaskBase* task);
|
||||
void finalize();
|
||||
|
||||
CriticalSection mCriticalSection;
|
||||
Framework* mParentFramework;
|
||||
DelegateThread* mPrepareThread;
|
||||
NullFaderTask* mNullFaderTask;
|
||||
TaskBase::List mPrepareList;
|
||||
TaskBase::List mPrepareDoneList;
|
||||
TaskBase::List mActiveList;
|
||||
TaskBase::List mStaticList;
|
||||
TaskBase::List mDyingList;
|
||||
TaskBase::List mDestroyableList;
|
||||
HeapArray mHeapArray;
|
||||
TaskCreateContextMgr* mTaskCreateContextMgr;
|
||||
u32 mMaxCreateQueueSize;
|
||||
TaskBase* mRootTask;
|
||||
TaskBase::CreateArg mRootTaskCreateArg;
|
||||
TaskMgr::InitializeArg mInitializeArg;
|
||||
MethodTreeNode mCalcDestructionTreeNode;
|
||||
u32 useless1;
|
||||
u32 useless2;
|
||||
};
|
||||
|
||||
} // namespace sead
|
||||
|
||||
#define SEAD_TASK_SINGLETON(CLASS) \
|
||||
public: \
|
||||
class SingletonDisposer_ \
|
||||
{ \
|
||||
public: \
|
||||
~SingletonDisposer_() \
|
||||
{ \
|
||||
if (mActive) \
|
||||
CLASS::sInstance = nullptr; \
|
||||
} \
|
||||
\
|
||||
bool mActive = false; \
|
||||
}; \
|
||||
\
|
||||
static CLASS* instance() { return sInstance; } \
|
||||
static void setInstance_(sead::TaskBase* task); \
|
||||
static void deleteInstance(); \
|
||||
\
|
||||
CLASS(const CLASS&) = delete; \
|
||||
CLASS& operator=(const CLASS&) = delete; \
|
||||
CLASS(CLASS&&) = delete; \
|
||||
CLASS& operator=(CLASS&&) = delete; \
|
||||
\
|
||||
protected: \
|
||||
static CLASS* sInstance; \
|
||||
\
|
||||
friend class SingletonDisposer_; \
|
||||
SingletonDisposer_ mSingletonDisposer;
|
||||
|
||||
#define SEAD_TASK_SINGLETON_IMPL(CLASS) \
|
||||
void CLASS::setInstance_(sead::TaskBase* task) \
|
||||
{ \
|
||||
if (!sInstance) \
|
||||
{ \
|
||||
sInstance = static_cast<CLASS*>(task); \
|
||||
sInstance->mSingletonDisposer.mActive = true; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
SEAD_ASSERT_MSG(false, "Create Singleton Twice (%s) : addr %p", #CLASS, sInstance); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void CLASS::deleteInstance() \
|
||||
{ \
|
||||
if (sInstance) \
|
||||
{ \
|
||||
sInstance->mTaskMgr->destroyTaskSync(sInstance); \
|
||||
sInstance = nullptr; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
CLASS* CLASS::sInstance = nullptr;
|
||||
|
||||
#endif // SEAD_TASKMGR_H_
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "prim/seadRuntimeTypeInfo.h"
|
||||
|
||||
namespace sead
|
||||
{
|
||||
class TaskParameter
|
||||
{
|
||||
SEAD_RTTI_BASE(TaskParameter)
|
||||
};
|
||||
} // namespace sead
|
||||
Reference in New Issue
Block a user