#include "dataLoader.h"

QVariant DataLoader::LoadTask::fetchRealData(const QString& key)
{
    //后续替换成实际接口
    return QVariant();
}

DataLoader::DataLoader(QObject* parent)
    : QObject(parent)
{
    m_threadPool.setMaxThreadCount(5);
}

DataLoader::~DataLoader()
{
    handleShutdown();
}

void DataLoader::requestData(const QString& dataKey)
{
    QMutexLocker lockder(&m_taskMutex);
    if(m_runningTasks.contains(dataKey))
        return;

    LoadTask* task = new LoadTask(this, dataKey);
    m_runningTasks.insert(dataKey, task);
    m_threadPool.start(task);
}

void DataLoader::handleShutdown()
{}
