AuroraRuntime/Include/Aurora/Async/IWorkItemHandler.hpp

47 lines
1.3 KiB
C++
Raw Normal View History

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IWorkItemHandler.hpp
Date: 2021-11-1
Author: Reece
***/
#pragma once
namespace Aurora::Async
{
AUE_DEFINE(ETickType,
(
eFinished,
eRerun,
eSchedule,
eFailed
));
struct IWorkItemHandler
{
struct ProcessInfo
{
inline ProcessInfo(bool finished) : type(finished ? ETickType::eFinished : ETickType::eFailed) {}
inline ProcessInfo(ETickType type) : type(type) {}
inline ProcessInfo(const AuList<AuSPtr<IWorkItem>> &blockedBy) : type(ETickType::eSchedule), waitFor(blockedBy) {}
// ...
ETickType type;
AuList<AuSPtr<IWorkItem>> waitFor;
AuUInt32 reschedMs {};
AuUInt64 reschedNs {};
AuUInt32 reschedClockAbsMs {};
AuUInt64 reschedClockAbsNs {};
// @hideinitializer
IThreadPool *pool;
};
virtual void DispatchFrame(ProcessInfo &info) = 0;
/// A really terrible name for the overloadable method that serves as the critical failure callback
/// This may run from any thread
virtual void OnFailure() {};
virtual void *GetPrivateData() { return nullptr; }
};
}