Squashed onto current main. Adds src/engine/common/Assert.h (EV_PARAM_CHECK / EV_ASSERT backed by zeroerr), an EVENGINE_ENABLE_ASSERTS option (non-Debug builds strip ZEROERR_NO_ASSERT unless enabled), parameter checks at key entry points, Doxygen comments across headers, Doxyfile + make docs / CMake docs targets, and Windows setup + code conventions in AGENTS.md.
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <condition_variable>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <string>
|
|
|
|
namespace eve {
|
|
namespace thread {
|
|
|
|
/**
|
|
* @brief A job executed by a ThreadPool worker.
|
|
* Status strings (no enums): "pending" | "running" | "done" | "failed".
|
|
*/
|
|
class Task {
|
|
public:
|
|
explicit Task(std::function<void()> fn);
|
|
~Task();
|
|
|
|
std::string getStatus() const;
|
|
bool isDone() const;
|
|
bool hasFailed() const;
|
|
std::string getError() const;
|
|
|
|
/** @brief Block until the task finishes (done or failed). */
|
|
void wait();
|
|
|
|
// Internal — called by ThreadPool workers.
|
|
void run();
|
|
|
|
private:
|
|
struct State {
|
|
explicit State(std::function<void()> taskFn) : fn(std::move(taskFn)) {}
|
|
|
|
std::function<void()> fn;
|
|
mutable std::mutex mu;
|
|
std::condition_variable cv;
|
|
std::string status = "pending";
|
|
std::string error;
|
|
};
|
|
|
|
explicit Task(std::shared_ptr<State> state);
|
|
static void run(const std::shared_ptr<State> &state);
|
|
|
|
std::shared_ptr<State> state_;
|
|
|
|
friend class ThreadPool;
|
|
};
|
|
|
|
} // namespace thread
|
|
} // namespace eve
|