#pragma once

#include <basis/seadTypes.h>
#include <mc/seadCoreInfo.h>
#include <prim/seadSafeString.h>

#include "Library/Thread/FunctorV0M.h"
#include "Project/Thread/InitializeThread.h"

namespace sead {
class DelegateThread;
class Thread;
}  // namespace sead

namespace al {
class AsyncFunctorThread {
public:
    AsyncFunctorThread(const sead::SafeString& functor_name, const FunctorBase& functor,
                       s32 priority, s32 stack_size, sead::CoreId id);
    virtual ~AsyncFunctorThread();

    void threadFunction(sead::Thread* unused_1, s64 unused_2);
    void start();
    bool isDone() const;

private:
    sead::DelegateThread* mDelegateThread = nullptr;
    FunctorBase* mFunctor = nullptr;
    bool mIsDone = true;
};

static_assert(sizeof(AsyncFunctorThread) == 0x20);

InitializeThread* createAndStartInitializeThread(sead::Heap* heap, s32 priority,
                                                 const FunctorBase& functor);
bool tryWaitDoneAndDestroyInitializeThread(InitializeThread* thread);
sead::CoreId getCurrentCoreId();
}  // namespace al
