idk
This commit is contained in:
+26
-11
@@ -6,27 +6,42 @@ using namespace Seele;
|
||||
std::mutex Seele::promisesLock;
|
||||
List<Promise*> Seele::promises;
|
||||
|
||||
Event::Event(nullptr_t)
|
||||
{
|
||||
}
|
||||
//Event::Event(nullptr_t)
|
||||
//{
|
||||
//}
|
||||
|
||||
Event::Event(const std::string &name, const std::source_location &location)
|
||||
: name(name)
|
||||
, location(location)
|
||||
, eventLock(std::make_unique<std::mutex>())
|
||||
{
|
||||
}
|
||||
|
||||
Event::Event(const std::source_location &location)
|
||||
: name(location.function_name())
|
||||
, location(location)
|
||||
, eventLock(std::make_unique<std::mutex>())
|
||||
{
|
||||
}
|
||||
|
||||
Event::Event(Event&& other)
|
||||
: name(std::move(other.name))
|
||||
, location(std::move(other.location))
|
||||
{
|
||||
}
|
||||
|
||||
Event& Event::operator=(Event&& other)
|
||||
{
|
||||
if(this != &other)
|
||||
{
|
||||
std::scoped_lock lock(eventLock, other.eventLock);
|
||||
name = std::move(other.name);
|
||||
location = std::move(other.location);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Event::raise()
|
||||
{
|
||||
std::scoped_lock lock(*eventLock);
|
||||
std::scoped_lock lock(eventLock);
|
||||
data = true;
|
||||
if(waitingJobs.size() > 0)
|
||||
{
|
||||
@@ -39,17 +54,17 @@ void Event::raise()
|
||||
}
|
||||
void Event::reset()
|
||||
{
|
||||
std::scoped_lock lock(*eventLock);
|
||||
std::scoped_lock lock(eventLock);
|
||||
data = false;
|
||||
}
|
||||
|
||||
bool Event::await_ready()
|
||||
{
|
||||
eventLock->lock();
|
||||
eventLock.lock();
|
||||
bool result = data;
|
||||
if(result)
|
||||
{
|
||||
eventLock->unlock();
|
||||
eventLock.unlock();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -58,14 +73,14 @@ void Event::await_suspend(std::coroutine_handle<JobPromiseBase<false>> h)
|
||||
{
|
||||
//h.promise().enqueue(this);
|
||||
waitingJobs.add(JobBase<false>(&h.promise()));
|
||||
eventLock->unlock();
|
||||
eventLock.unlock();
|
||||
}
|
||||
|
||||
void Event::await_suspend(std::coroutine_handle<JobPromiseBase<true>> h)
|
||||
{
|
||||
//h.promise().enqueue(this);
|
||||
waitingMainJobs.add(JobBase<true>(&h.promise()));
|
||||
eventLock->unlock();
|
||||
eventLock.unlock();
|
||||
}
|
||||
|
||||
ThreadPool::ThreadPool(uint32 threadCount)
|
||||
|
||||
+19
-13
@@ -16,14 +16,14 @@ struct JobPromiseBase;
|
||||
struct Event
|
||||
{
|
||||
public:
|
||||
Event(nullptr_t);
|
||||
//Event(nullptr_t);
|
||||
Event(const std::string& name, const std::source_location& location = std::source_location::current());
|
||||
Event(const std::source_location& location = std::source_location::current());
|
||||
Event(const Event& other) = delete;
|
||||
Event(Event&& other) = default;
|
||||
Event(Event&& other);
|
||||
~Event() = default;
|
||||
Event& operator=(const Event& other) = delete;
|
||||
Event& operator=(Event&& other) = default;
|
||||
Event& operator=(Event&& other);
|
||||
auto operator<=>(const Event& other) const
|
||||
{
|
||||
return name <=> other.name;
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
}
|
||||
operator bool()
|
||||
{
|
||||
std::scoped_lock lock(*eventLock);
|
||||
std::scoped_lock lock(eventLock);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
private:
|
||||
std::string name;
|
||||
std::source_location location;
|
||||
std::unique_ptr<std::mutex> eventLock;
|
||||
std::mutex eventLock;
|
||||
bool data = false;
|
||||
Array<JobBase<false>> waitingJobs;
|
||||
Array<JobBase<true>> waitingMainJobs;
|
||||
@@ -81,8 +81,14 @@ struct JobPromiseBase
|
||||
DONE
|
||||
};
|
||||
JobPromiseBase(const std::source_location& location = std::source_location::current())
|
||||
: handle(std::coroutine_handle<JobPromiseBase<MainJob>>::from_promise(*this))
|
||||
, finishedEvent(Event(location))
|
||||
: pad0(0x7472617453)
|
||||
, handle(std::coroutine_handle<JobPromiseBase<MainJob>>::from_promise(*this))
|
||||
, waitingFor(nullptr)
|
||||
, continuation(nullptr)
|
||||
, numRefs(0)
|
||||
, finishedEvent(location)
|
||||
, state(State::READY)
|
||||
, pad1(0x646E45)
|
||||
{
|
||||
if constexpr(!MainJob)
|
||||
{
|
||||
@@ -165,14 +171,14 @@ struct JobPromiseBase
|
||||
}
|
||||
}
|
||||
}
|
||||
uint64 pad0 = 0x7472617453;
|
||||
uint64 pad0;
|
||||
std::coroutine_handle<JobPromiseBase> handle;
|
||||
Event* waitingFor = nullptr;
|
||||
JobPromiseBase* continuation = nullptr;
|
||||
uint64 numRefs = 0;
|
||||
Event* waitingFor;
|
||||
JobPromiseBase* continuation;
|
||||
uint64 numRefs;
|
||||
Event finishedEvent;
|
||||
State state = State::READY;
|
||||
uint64 pad1 = 0x646E45;
|
||||
State state;
|
||||
uint64 pad1;
|
||||
};
|
||||
|
||||
template<bool MainJob = false>
|
||||
|
||||
@@ -35,9 +35,9 @@ Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const Viewpo
|
||||
//AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Ely\\Ely.fbx");
|
||||
//AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Cube\\cube.obj");
|
||||
//AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Plane\\plane.fbx");
|
||||
PPrimitiveComponent plane = new PrimitiveComponent(AssetRegistry::findMesh("plane"));
|
||||
plane->setRelativeScale(Vector(100, 100, 100));
|
||||
scene->addPrimitiveComponent(plane);
|
||||
//PPrimitiveComponent plane = new PrimitiveComponent(AssetRegistry::findMesh("plane"));
|
||||
//plane->setRelativeScale(Vector(100, 100, 100));
|
||||
//scene->addPrimitiveComponent(plane);
|
||||
|
||||
for(uint32 i = 0; i < 100000; ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user