2024-02-05 22:25:30 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "EHS.h"
|
|
|
|
#include "BaseObj.h"
|
|
|
|
#include "ehs/system/Thread.h"
|
|
|
|
#include "ehs/system/Semaphore.h"
|
|
|
|
|
|
|
|
namespace ehs
|
|
|
|
{
|
|
|
|
typedef void (*TaskCb)(Serializer<UInt_64>*);
|
|
|
|
|
2024-07-24 01:36:20 -07:00
|
|
|
class EHS_LIB_IO Task
|
2024-02-05 22:25:30 -08:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
bool working;
|
|
|
|
Semaphore* available;
|
|
|
|
Semaphore* done;
|
|
|
|
Serializer<UInt_64>** cbArgs;
|
|
|
|
TaskCb* callback;
|
|
|
|
Serializer<UInt_64>* 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<UInt_64> args, TaskCb cb);
|
|
|
|
|
|
|
|
void WaitUntilDone();
|
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
};
|
|
|
|
}
|