#ifndef TILE_BASE_INTERNAL_BACKGROUND_TASK_HOST_H
#define TILE_BASE_INTERNAL_BACKGROUND_TASK_HOST_H

#pragma once

#include "tile/base/internal/thread_pool.h"
#include "tile/base/never_destroyed.h"

#include <functional>
#include <memory>
#include <vector>

namespace tile {
namespace internal {
class BackgroundTaskHost {
public:
    static BackgroundTaskHost *Instance();
    void Start();
    void Stop();
    void Join();

    void Queue(std::function<void()> &&op);

private:
    friend class NeverDestroyedSingleton<BackgroundTaskHost>;
    BackgroundTaskHost();

private:
    std::vector<std::unique_ptr<ThreadPool>> pools_;
};
}// namespace internal
}// namespace tile

#endif// TILE_BASE_INTERNAL_BACKGROUND_TASK_HOST_H
