AuroraRuntime/Include/Aurora/Async/Async.hpp

59 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();
/// Async app only | Thread pools must use the IThreadPool::NewFence function
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerId_t &worker, const AuSPtr<IWorkItemHandler> &task, bool supportsBlocking = false);
/**
* @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
* @param supportsBlocking Optimization hint for IWorkItem::BlockUntilComplete()
* @return
*/
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerPId_t &worker, const AuSPtr<IWorkItemHandler> &task, bool supportsBlocking = false);
/// Async app only | Thread pools must use the IThreadPool::NewFence function
AUKN_SYM AuSPtr<IWorkItem> NewFence();
/// Allocates a new thread pool for usage
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