Update headers, untabify. I guess the vs extension killed itself

This commit is contained in:
Reece Wilson 2021-06-27 22:33:58 +01:00
parent eb4a495199
commit 337062b490
13 changed files with 122 additions and 59 deletions

View File

@ -22,35 +22,35 @@ namespace Aurora::Async
using WorkerId_t = std::pair<ThreadGroup_t, ThreadId_t>; using WorkerId_t = std::pair<ThreadGroup_t, ThreadId_t>;
using DispatchTarget_t = std::pair<ThreadGroup_t, std::optional<ThreadId_t>>; using DispatchTarget_t = std::pair<ThreadGroup_t, std::optional<ThreadId_t>>;
struct IWorkItemHandler struct IWorkItemHandler
{ {
enum class EProcessNext enum class EProcessNext
{ {
eInvalid = -1, eInvalid = -1,
eFinished = 0, eFinished = 0,
eRerun, eRerun,
eSchedule, eSchedule,
eFailed eFailed
}; };
struct ProcessInfo struct ProcessInfo
{ {
ProcessInfo(bool finished) : type(finished ? EProcessNext::eFinished : EProcessNext::eFailed) {} ProcessInfo(bool finished) : type(finished ? EProcessNext::eFinished : EProcessNext::eFailed) {}
ProcessInfo(EProcessNext type) : type(type) {} ProcessInfo(EProcessNext type) : type(type) {}
ProcessInfo(const AuList<AuSPtr<IWorkItem>> &blockedBy) : type(EProcessNext::eSchedule), waitFor(blockedBy) {} ProcessInfo(const AuList<AuSPtr<IWorkItem>> &blockedBy) : type(EProcessNext::eSchedule), waitFor(blockedBy) {}
// ... // ...
EProcessNext type; EProcessNext type;
AuList<AuSPtr<IWorkItem>> waitFor; AuList<AuSPtr<IWorkItem>> waitFor;
AuUInt32 reschedMs; AuUInt32 reschedMs;
//AuUInt64 reschedNs; //AuUInt64 reschedNs;
}; };
virtual void DispatchFrame(ProcessInfo &info) = 0; virtual void DispatchFrame(ProcessInfo &info) = 0;
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
}; };
template<typename Info_t = AVoid, typename Result_t = AVoid> template<typename Info_t = AVoid, typename Result_t = AVoid>
struct FJob struct FJob
{ {
@ -64,8 +64,8 @@ namespace Aurora::Async
void(* onSuccess)(const Info_t &, const Result_t &); // void(* onSuccess)(const Info_t &, const Result_t &); //
void(* onFailure)(const Info_t &, bool taskNeverDispatched); // called from caller thread if taskNeverDispatched void(* onFailure)(const Info_t &, bool taskNeverDispatched); // called from caller thread if taskNeverDispatched
}; };
template<typename Info_t = AVoid, typename Result_t = AVoid> template<typename Info_t = AVoid, typename Result_t = AVoid>
struct FTask struct FTask
{ {
std::function<std::optional<Result_t>(const Info_t &)> onFrame = 0; std::function<std::optional<Result_t>(const Info_t &)> onFrame = 0;
@ -76,7 +76,7 @@ namespace Aurora::Async
{ {
std::optional<Result_t>(* onFrame)(const Info_t &); std::optional<Result_t>(* onFrame)(const Info_t &);
}; };
class IWorkItem class IWorkItem
{ {
@ -99,7 +99,7 @@ namespace Aurora::Async
{ {
std::function<void()> callback; std::function<void()> callback;
std::function<void()> error; std::function<void()> error;
BasicWorkStdFunc(std::function<void()> &&callback, std::function<void()> &&error) : callback(std::move(callback)), error(std::move(error)) BasicWorkStdFunc(std::function<void()> &&callback, std::function<void()> &&error) : callback(std::move(callback)), error(std::move(error))
{} {}
@ -114,19 +114,19 @@ namespace Aurora::Async
private: private:
void DispatchFrame(ProcessInfo &info) override void DispatchFrame(ProcessInfo &info) override
{ {
try try
{ {
callback(); callback();
} }
catch (...) catch (...)
{ {
Debug::PrintError(); Debug::PrintError();
} }
} }
void Shutdown() override void Shutdown() override
{ {
try try
{ {
@ -139,7 +139,7 @@ namespace Aurora::Async
} }
}; };
template<typename Info_t, typename Result_t, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>> template<typename Info_t, typename Result_t, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>>
struct BasicWorkCallback : IWorkItemHandler, std::enable_shared_from_this<IWorkItemHandler> struct BasicWorkCallback : IWorkItemHandler, std::enable_shared_from_this<IWorkItemHandler>
{ {
BasicWorkCallback() BasicWorkCallback()
@ -152,15 +152,15 @@ namespace Aurora::Async
Info_t input; Info_t input;
private: private:
static constexpr bool IsCallbackPtr = std::is_pointer_v<Job_t> || is_base_of_template<AuSPtr, Job_t>; static constexpr bool IsCallbackPtr = std::is_pointer_v<Job_t> || is_base_of_template<AuSPtr, Job_t>;
static constexpr bool IsTaskPtr = std::is_pointer_v<Task_t> || is_base_of_template<AuSPtr, Task_t>; static constexpr bool IsTaskPtr = std::is_pointer_v<Task_t> || is_base_of_template<AuSPtr, Task_t>;
WorkerId_t caller; WorkerId_t caller;
void DispatchFrame(ProcessInfo &info) override void DispatchFrame(ProcessInfo &info) override
{ {
std::optional<Result_t> ret; std::optional<Result_t> ret;
if constexpr (IsTaskPtr) if constexpr (IsTaskPtr)
@ -237,10 +237,10 @@ namespace Aurora::Async
Debug::PrintError(); Debug::PrintError();
Shutdown(); Shutdown();
} }
} }
void Shutdown() override void Shutdown() override
{ {
try try
{ {
if constexpr (IsCallbackPtr) if constexpr (IsCallbackPtr)
@ -256,10 +256,10 @@ namespace Aurora::Async
{ {
Debug::PrintError(); Debug::PrintError();
} }
} }
}; };
template<typename Frame_t = std::function<void()>, typename Cleanup_t = std::function<void()>> template<typename Frame_t = std::function<void()>, typename Cleanup_t = std::function<void()>>
struct WorkItemCallabale : IWorkItemHandler struct WorkItemCallabale : IWorkItemHandler
{ {
Frame_t frame; Frame_t frame;

View File

@ -1,7 +1,7 @@
/*** /***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ModuleInfo.hpp File: ProcessMap.hpp
Date: 2021-6-10 Date: 2021-6-10
Author: Reece Author: Reece
***/ ***/

View File

@ -1,7 +1,7 @@
/*** /***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ConditionalEx.hpp File: ConditionEx.hpp
Date: 2021-6-11 Date: 2021-6-11
Author: Reece Author: Reece
***/ ***/

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IThreadFeature.hpp
Date: 2021-6-25
Author: Reece
***/
#pragma once #pragma once
namespace Aurora::Threading::Threads namespace Aurora::Threading::Threads

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Async.cpp
Date: 2021-6-26
Author: Reece
***/
#include <RuntimeInternal.hpp> #include <RuntimeInternal.hpp>
#include "Async.hpp" #include "Async.hpp"

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Async.hpp
Date: 2021-6-26
Author: Reece
***/
#pragma once #pragma once
namespace Aurora::Async namespace Aurora::Async

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AsyncApp.cpp
Date: 2021-6-26
Author: Reece
***/
#include <RuntimeInternal.hpp> #include <RuntimeInternal.hpp>
#include "AsyncApp.hpp" #include "AsyncApp.hpp"

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AsyncApp.hpp
Date: 2021-6-26
Author: Reece
***/
#pragma once #pragma once
namespace Aurora::Async namespace Aurora::Async

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Schedular.cpp
Date: 2021-6-26
Author: Reece
***/
#include <RuntimeInternal.hpp> #include <RuntimeInternal.hpp>
#include "Schedular.hpp" #include "Schedular.hpp"

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Schedular.hpp
Date: 2021-6-26
Author: Reece
***/
#pragma once #pragma once
namespace Aurora::Async namespace Aurora::Async

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: WorkItem.cpp
Date: 2021-6-26
Author: Reece
***/
#include <RuntimeInternal.hpp> #include <RuntimeInternal.hpp>
#include "WorkItem.hpp" #include "WorkItem.hpp"

View File

@ -1,3 +1,10 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: WorkItem.hpp
Date: 2021-6-26
Author: Reece
***/
#pragma once #pragma once
namespace Aurora::Async namespace Aurora::Async

View File

@ -39,58 +39,58 @@ namespace Aurora::Threading::Primitives
bool RWLockImpl::LockRead(AuUInt64 timeout) bool RWLockImpl::LockRead(AuUInt64 timeout)
{ {
LockGuardPtr<IConditionMutex> mutex(mutex_.get()); LockGuardPtr<IConditionMutex> mutex(mutex_.get());
while (state_ < 0) while (state_ < 0)
{ {
if (!condition_->WaitForSignal(timeout)) if (!condition_->WaitForSignal(timeout))
{ {
return false; return false;
} }
} }
state_++; state_++;
return true; return true;
} }
bool RWLockImpl::LockWrite(AuUInt64 timeout) bool RWLockImpl::LockWrite(AuUInt64 timeout)
{ {
LockGuardPtr<IConditionMutex> mutex(mutex_.get()); LockGuardPtr<IConditionMutex> mutex(mutex_.get());
while (state_ != 0) while (state_ != 0)
{ {
if (!condition_->WaitForSignal(timeout)) if (!condition_->WaitForSignal(timeout))
{ {
return false; return false;
} }
} }
state_ = -1; state_ = -1;
return true; return true;
} }
bool RWLockImpl::TryLockRead() bool RWLockImpl::TryLockRead()
{ {
LockGuardPtr<IConditionMutex> mutex(mutex_.get()); LockGuardPtr<IConditionMutex> mutex(mutex_.get());
if (state_ == -1) if (state_ == -1)
{ {
return false; return false;
} }
state_++; state_++;
return true; return true;
} }
bool RWLockImpl::TryLockWrite() bool RWLockImpl::TryLockWrite()
{ {
LockGuardPtr<IConditionMutex> mutex(mutex_.get()); LockGuardPtr<IConditionMutex> mutex(mutex_.get());
if (state_ > 0) if (state_ > 0)
{ {
return false; return false;
} }
state_ = -1; state_ = -1;
return true; return true;
} }
@ -98,10 +98,10 @@ namespace Aurora::Threading::Primitives
{ {
LockGuardPtr<IConditionMutex> mutex(mutex_.get()); LockGuardPtr<IConditionMutex> mutex(mutex_.get());
if(--state_ == 0) if(--state_ == 0)
{ {
condition_->Signal(); condition_->Signal();
} }
} }
void RWLockImpl::UnlockWrite() void RWLockImpl::UnlockWrite()