#include "datamanagerthread.h"
#include <QDebug>

DataManagerThread::DataManagerThread()
{
    manager = nullptr;
    isExit = false;
    toManager = false;
}

void DataManagerThread::run()
{
    while(!isExit)
    {
        qDebug() << "run";
        while(toManager)
        {
            if(manager)
            {
                manager->doExcute();
                emit managerFinished();
            }
            toManager = false;
            manager = nullptr;
        }
        sleep(1);
    }
}

int DataManagerThread::startManager()
{
    if(!manager || isExit)
        return -1;
    toManager = true;
    return 1;
}
