Files
botw/lib/sead/include/mc/seadWorker.h
T
Léo Lam 18c60323a9 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"
2022-03-21 21:31:42 +01:00

54 lines
1.5 KiB
C++

#pragma once
#include "container/seadRingBuffer.h"
#include "mc/seadJobQueue.h"
#include "prim/seadEnum.h"
#include "prim/seadSafeString.h"
#include "thread/seadEvent.h"
#include "thread/seadThread.h"
#include "time/seadTickTime.h"
namespace sead
{
class WorkerMgr;
SEAD_ENUM(JobQueuePushType, cForward, cBackward)
class Worker : public Thread
{
public:
static constexpr MessageQueue::Element cMsg_Process = 1;
SEAD_ENUM(State, cSleep, cWakeup, cRunning, cRunning_WaitLock, cRunning_GetLock, cRunning_Run,
cRunning_AfterRun, cRunning_BeforeReturn, cRunning_AllJobDoneReturn, cFinished,
cWaitingAtWorker)
Worker(WorkerMgr* mgr, u32 num_jobs, s32 stack_size, s32 priority, const SafeString& name);
bool pushJobQueue(const char* name, JobQueue* queue, JobQueuePushType type);
void clearJobQQ();
void setState(Worker::State state) { mWorkerState = state; }
protected:
friend class WorkerMgr;
void calc_(MessageQueue::Element msg) override;
virtual void proc_();
JobQueue* getNextJQ_();
void wakeup_(MessageQueue::Element msg);
CoreId mCore = 0;
Atomic<Worker::State> mWorkerState{sead::AtomicDirectInitTag{}, Worker::State::cSleep};
WorkerMgr* mMgr = nullptr;
RingBuffer<JobQueue*> mJobQueues;
JobQueueLock mLock;
JobQueue* mCurrentQueue = nullptr;
const char* mCurrentQueueDescription = nullptr;
u32 mNumRuns = 0;
TickTime mLastRun;
Event mEvent{true};
};
} // namespace sead