69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: Async.hpp
|
|
Date: 2021-7-14
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "AsyncTypes.hpp"
|
|
|
|
#include "IWorkItem.hpp"
|
|
#include "IWorkItemHandler.hpp"
|
|
#include "IThreadPool.hpp"
|
|
#include "IAsyncApp.hpp"
|
|
|
|
#include "Legacy/Jobs.hpp"
|
|
#include "Legacy/Tasks.hpp"
|
|
|
|
namespace Aurora::Async
|
|
{
|
|
AUKN_SYM IAsyncApp * GetAsyncApp();
|
|
AUKN_SYM AuSPtr<IAsyncApp> GetSharedAsyncApp();
|
|
|
|
///
|
|
AUKN_SYM WorkerPId_t GetCurrentWorkerPId();
|
|
|
|
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerId_t &worker, const AuSPtr<IWorkItemHandler> &task);
|
|
|
|
/**
|
|
* @brief Creates an asynchronous job object to be executed on an async runner
|
|
* @param worker A worker id pair. Supports AuAsync::kThreadIdAny to run on any runner within the group.
|
|
* @param task An interface to run the job/work/task in question
|
|
* @return
|
|
*/
|
|
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerPId_t &worker, const AuSPtr<IWorkItemHandler> &task);
|
|
|
|
/**
|
|
* @brief
|
|
* @param worker
|
|
* @param func
|
|
* @return
|
|
*/
|
|
AUKN_SYM AuSPtr<IWorkItem> NewWorkFunction(const WorkerPId_t &worker, AuVoidFunc func);
|
|
|
|
static inline AuSPtr<IWorkItem> DispatchOn(const WorkerPId_t &worker, AuVoidFunc func)
|
|
{
|
|
auto pThat = NewWorkFunction(worker, func);
|
|
SysAssert(pThat);
|
|
return pThat->Dispatch();
|
|
}
|
|
|
|
AUKN_SYM AuSPtr<IWorkItem> NewFence();
|
|
|
|
AUKN_SYM AuSPtr<IThreadPool> NewThreadPool();
|
|
|
|
AUKN_SYM void SetMainThreadForSysPumpScheduling(WorkerPId_t pid);
|
|
}
|
|
|
|
#if !defined(_CPPSHARP)
|
|
#include "IPCPromises.hpp"
|
|
|
|
#include "Legacy/JobFrom.hpp"
|
|
#include "Legacy/TaskFrom.hpp"
|
|
#include "Legacy/WorkPairImpl.hpp"
|
|
#include "Legacy/WorkBasic.hpp"
|
|
#include "Legacy/OldTrash.hpp"
|
|
#endif
|