AuroraRuntime/Include/Aurora/Async/IWorkItemHandler.hpp

41 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
{
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 {};
AuUInt64 reschedSteadyClockAbsNs {};
AuSPtr<IO::Loop::ILoopSource> pLoopSource {};
// @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
inline virtual void OnFailure() {};
inline virtual void *GetPrivateData() { return nullptr; }
};
}