Example #1
0
bool TrainingThread::stop(){

    if( !getThreadRunning() ){
        if( verbose ){
            qDebug() << "WARNING: TrainingThread::stop() - The thread is not running!" << endl;
            emit newInfoMessage( "WARNING: Failed to stop thread, it is not running!" );
        }
        return false;
    }

    if( verbose )
        qDebug() << STRING_TO_QSTRING("TrainingThread::stop() - Stopping training thread...");

    //Flag that the core should stop
    {
        boost::mutex::scoped_lock lock( mutex );
        stopMainThread = true;
    }

    //Wait for it to stop
    mainThread->join();
    mainThread.reset();

    return true;
}
Example #2
0
bool TrainingThread::start(){

    if( getThreadRunning() ){
        if( verbose ){
            qDebug() << "WARNING: TrainingThread::start() - The thread is already running!" << endl;
            emit newInfoMessage( "WARNING: Failed to start training thread, it is already running!" );
        }
        return false;
    }

    if( verbose )
        qDebug() << STRING_TO_QSTRING("TrainingThread::start() - Starting training thread...");

    try{
        mainThread.reset( new boost::thread( boost::bind( &TrainingThread::mainThreadFunction, this) ) );
    }catch( std::exception const &error ){
        QString qstr = "ERROR: Core::start() - Failed to start training thread! Exception: ";
        qstr += error.what();
        qstr += "\n";
        qDebug() << qstr;
        return false;
    }

    return true;
}
Example #3
0
void RestoreFrame::updateControls()
{
    bool running = getThreadRunning();
    button_browse->Enable(!running);
    text_ctrl_filename->Enable(!running);
    checkbox_replace->Enable(!running);
    checkbox_deactivate->Enable(!running);
    checkbox_noshadow->Enable(!running);
    checkbox_validity->Enable(!running);
    checkbox_commit->Enable(!running);
    checkbox_space->Enable(!running);
    choice_pagesize->Enable(!running);
    DatabasePtr db = getDatabase();
    button_start->Enable(!running && !text_ctrl_filename->GetValue().empty()
        && db && !db->isConnected());
}
Example #4
0
TrainingThread::~TrainingThread(){
    if( getThreadRunning() ){
        stop();
    }
}