2023-12-17 03:29:08 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "EHS.h"
|
|
|
|
#include "BaseObj.h"
|
2023-12-17 15:56:13 -08:00
|
|
|
#include "system/Thread.h"
|
|
|
|
#include "system/Semaphore.h"
|
2023-12-17 03:29:08 -08:00
|
|
|
|
2023-12-17 15:56:13 -08:00
|
|
|
namespace ehs
|
2023-12-17 03:29:08 -08:00
|
|
|
{
|
|
|
|
typedef void (*TaskCb)(Serializer<UInt_64>*);
|
|
|
|
|
|
|
|
class Task
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|