#pragma once #include "EHS.h" #include "BaseObj.h" #include "system/Thread.h" #include "system/Semaphore.h" namespace ehs { typedef void (*TaskCb)(Serializer*); class Task { private: bool working; Semaphore* available; Semaphore* done; Serializer** cbArgs; TaskCb* callback; Serializer* threadArgs; Thread thread; public: ~Task(); Task(); Task(Task&& task) noexcept; Task(const Task& task); Task& operator=(Task&& task) noexcept; Task& operator=(const Task& task); void Revalidate(); void Initialize(); void Release(); bool IsWorking() const; void GiveWork(Serializer args, TaskCb cb); void WaitUntilDone(); bool IsValid() const; }; }