// D:\Dev\Mosis\MosisService\designer\src\hot_reload.h
#pragma once

#include <filesystem>
#include <functional>
#include <thread>
#include <atomic>

namespace mosis {

class HotReload {
public:
    using ReloadCallback = std::function<void()>;

    HotReload(const std::filesystem::path& watch_path, ReloadCallback callback);
    ~HotReload();

    void Start();
    void Stop();
    bool IsRunning() const { return m_running; }

private:
    void WatchThread();

    std::filesystem::path m_watch_path;
    ReloadCallback m_callback;
    std::thread m_watch_thread;
    std::atomic<bool> m_running{false};

#ifdef _WIN32
    void* m_notification_handle = nullptr;  // HANDLE
    void* m_stop_event = nullptr;           // HANDLE for signaling shutdown
#endif
};

} // namespace mosis
