2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Async.hpp
|
2021-09-06 10:58:08 +00:00
|
|
|
Date: 2021-7-14
|
2021-06-27 21:25:29 +00:00
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
#include "AsyncTypes.hpp"
|
2021-09-29 10:47:54 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
#include "IWorkItem.hpp"
|
|
|
|
#include "IWorkItemHandler.hpp"
|
|
|
|
#include "IThreadPool.hpp"
|
|
|
|
#include "IAsyncApp.hpp"
|
2021-09-29 14:31:40 +00:00
|
|
|
|
2022-08-02 04:52:17 +00:00
|
|
|
#include "Legacy/Jobs.hpp"
|
|
|
|
#include "Legacy/Tasks.hpp"
|
2021-09-29 14:31:40 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
namespace Aurora::Async
|
|
|
|
{
|
2022-08-20 06:53:48 +00:00
|
|
|
AUKN_SYM IAsyncApp * GetAsyncApp();
|
2022-03-23 16:33:02 +00:00
|
|
|
AUKN_SYM AuSPtr<IAsyncApp> GetSharedAsyncApp();
|
2021-09-29 12:36:25 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
///
|
|
|
|
AUKN_SYM WorkerPId_t GetCurrentWorkerPId();
|
2022-03-20 09:56:15 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
/// 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);
|
2022-03-20 09:56:15 +00:00
|
|
|
|
2022-08-20 06:53:48 +00:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2021-11-05 17:34:23 +00:00
|
|
|
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerPId_t &worker, const AuSPtr<IWorkItemHandler> &task, bool supportsBlocking = false);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
/// Async app only | Thread pools must use the IThreadPool::NewFence function
|
2021-10-06 13:48:28 +00:00
|
|
|
AUKN_SYM AuSPtr<IWorkItem> NewFence();
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
/// Allocates a new thread pool for usage
|
|
|
|
AUKN_SYM AuSPtr<IThreadPool> NewThreadPool();
|
2022-05-09 18:27:36 +00:00
|
|
|
///
|
2022-08-20 06:53:48 +00:00
|
|
|
|
2022-05-09 18:27:36 +00:00
|
|
|
AUKN_SYM void SetMainThreadForSysPumpScheduling(WorkerPId_t pid);
|
2021-10-02 16:07:33 +00:00
|
|
|
}
|
2021-11-05 17:34:23 +00:00
|
|
|
|
|
|
|
#if !defined(_CPPSHARP)
|
2022-07-19 15:29:20 +00:00
|
|
|
#include "IPCPromises.hpp"
|
|
|
|
|
2022-08-02 04:52:17 +00:00
|
|
|
#include "Legacy/JobFrom.hpp"
|
|
|
|
#include "Legacy/TaskFrom.hpp"
|
|
|
|
#include "Legacy/WorkPairImpl.hpp"
|
|
|
|
#include "Legacy/WorkBasic.hpp"
|
|
|
|
#include "Legacy/OldTrash.hpp"
|
2022-03-20 09:56:15 +00:00
|
|
|
#endif
|