Update headers, untabify. I guess the vs extension killed itself
This commit is contained in:
parent
eb4a495199
commit
337062b490
@ -22,35 +22,35 @@ namespace Aurora::Async
|
||||
using WorkerId_t = std::pair<ThreadGroup_t, ThreadId_t>;
|
||||
using DispatchTarget_t = std::pair<ThreadGroup_t, std::optional<ThreadId_t>>;
|
||||
|
||||
struct IWorkItemHandler
|
||||
{
|
||||
enum class EProcessNext
|
||||
{
|
||||
eInvalid = -1,
|
||||
eFinished = 0,
|
||||
eRerun,
|
||||
eSchedule,
|
||||
struct IWorkItemHandler
|
||||
{
|
||||
enum class EProcessNext
|
||||
{
|
||||
eInvalid = -1,
|
||||
eFinished = 0,
|
||||
eRerun,
|
||||
eSchedule,
|
||||
eFailed
|
||||
};
|
||||
};
|
||||
|
||||
struct ProcessInfo
|
||||
{
|
||||
ProcessInfo(bool finished) : type(finished ? EProcessNext::eFinished : EProcessNext::eFailed) {}
|
||||
ProcessInfo(EProcessNext type) : type(type) {}
|
||||
ProcessInfo(const AuList<AuSPtr<IWorkItem>> &blockedBy) : type(EProcessNext::eSchedule), waitFor(blockedBy) {}
|
||||
// ...
|
||||
struct ProcessInfo
|
||||
{
|
||||
ProcessInfo(bool finished) : type(finished ? EProcessNext::eFinished : EProcessNext::eFailed) {}
|
||||
ProcessInfo(EProcessNext type) : type(type) {}
|
||||
ProcessInfo(const AuList<AuSPtr<IWorkItem>> &blockedBy) : type(EProcessNext::eSchedule), waitFor(blockedBy) {}
|
||||
// ...
|
||||
|
||||
EProcessNext type;
|
||||
AuList<AuSPtr<IWorkItem>> waitFor;
|
||||
AuUInt32 reschedMs;
|
||||
//AuUInt64 reschedNs;
|
||||
};
|
||||
EProcessNext type;
|
||||
AuList<AuSPtr<IWorkItem>> waitFor;
|
||||
AuUInt32 reschedMs;
|
||||
//AuUInt64 reschedNs;
|
||||
};
|
||||
|
||||
virtual void DispatchFrame(ProcessInfo &info) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
};
|
||||
|
||||
|
||||
virtual void DispatchFrame(ProcessInfo &info) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
};
|
||||
|
||||
|
||||
template<typename Info_t = AVoid, typename Result_t = AVoid>
|
||||
struct FJob
|
||||
{
|
||||
@ -64,8 +64,8 @@ namespace Aurora::Async
|
||||
void(* onSuccess)(const Info_t &, const Result_t &); //
|
||||
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
|
||||
{
|
||||
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 &);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class IWorkItem
|
||||
{
|
||||
@ -99,7 +99,7 @@ namespace Aurora::Async
|
||||
{
|
||||
std::function<void()> callback;
|
||||
std::function<void()> 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:
|
||||
|
||||
void DispatchFrame(ProcessInfo &info) override
|
||||
{
|
||||
void DispatchFrame(ProcessInfo &info) override
|
||||
{
|
||||
try
|
||||
{
|
||||
callback();
|
||||
callback();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Debug::PrintError();
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
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>
|
||||
{
|
||||
BasicWorkCallback()
|
||||
@ -152,15 +152,15 @@ namespace Aurora::Async
|
||||
|
||||
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 IsTaskPtr = std::is_pointer_v<Task_t> || is_base_of_template<AuSPtr, Task_t>;
|
||||
|
||||
WorkerId_t caller;
|
||||
|
||||
void DispatchFrame(ProcessInfo &info) override
|
||||
{
|
||||
void DispatchFrame(ProcessInfo &info) override
|
||||
{
|
||||
std::optional<Result_t> ret;
|
||||
|
||||
if constexpr (IsTaskPtr)
|
||||
@ -237,10 +237,10 @@ namespace Aurora::Async
|
||||
Debug::PrintError();
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
try
|
||||
{
|
||||
if constexpr (IsCallbackPtr)
|
||||
@ -256,10 +256,10 @@ namespace Aurora::Async
|
||||
{
|
||||
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
|
||||
{
|
||||
Frame_t frame;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: ModuleInfo.hpp
|
||||
File: ProcessMap.hpp
|
||||
Date: 2021-6-10
|
||||
Author: Reece
|
||||
***/
|
||||
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: ConditionalEx.hpp
|
||||
File: ConditionEx.hpp
|
||||
Date: 2021-6-11
|
||||
Author: Reece
|
||||
***/
|
||||
|
@ -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
|
||||
|
||||
namespace Aurora::Threading::Threads
|
||||
|
@ -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 "Async.hpp"
|
||||
|
||||
|
@ -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
|
||||
|
||||
namespace Aurora::Async
|
||||
|
@ -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 "AsyncApp.hpp"
|
||||
|
||||
|
@ -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
|
||||
|
||||
namespace Aurora::Async
|
||||
|
@ -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 "Schedular.hpp"
|
||||
|
||||
|
@ -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
|
||||
|
||||
namespace Aurora::Async
|
||||
|
@ -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 "WorkItem.hpp"
|
||||
|
||||
|
@ -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
|
||||
|
||||
namespace Aurora::Async
|
||||
|
@ -39,58 +39,58 @@ namespace Aurora::Threading::Primitives
|
||||
bool RWLockImpl::LockRead(AuUInt64 timeout)
|
||||
{
|
||||
LockGuardPtr<IConditionMutex> mutex(mutex_.get());
|
||||
|
||||
|
||||
while (state_ < 0)
|
||||
{
|
||||
if (!condition_->WaitForSignal(timeout))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state_++;
|
||||
state_++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RWLockImpl::LockWrite(AuUInt64 timeout)
|
||||
{
|
||||
LockGuardPtr<IConditionMutex> mutex(mutex_.get());
|
||||
|
||||
|
||||
while (state_ != 0)
|
||||
{
|
||||
if (!condition_->WaitForSignal(timeout))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state_ = -1;
|
||||
state_ = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RWLockImpl::TryLockRead()
|
||||
{
|
||||
LockGuardPtr<IConditionMutex> mutex(mutex_.get());
|
||||
|
||||
|
||||
if (state_ == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
state_++;
|
||||
state_++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RWLockImpl::TryLockWrite()
|
||||
{
|
||||
LockGuardPtr<IConditionMutex> mutex(mutex_.get());
|
||||
|
||||
|
||||
if (state_ > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
state_ = -1;
|
||||
state_ = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -98,10 +98,10 @@ namespace Aurora::Threading::Primitives
|
||||
{
|
||||
LockGuardPtr<IConditionMutex> mutex(mutex_.get());
|
||||
|
||||
if(--state_ == 0)
|
||||
if(--state_ == 0)
|
||||
{
|
||||
condition_->Signal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RWLockImpl::UnlockWrite()
|
||||
|
Loading…
Reference in New Issue
Block a user