<commit_before>//
// Created by vrosca on 1/12/17.
//

#include <future>
#include <chrono>
#include "SearchButton.hpp"
#include "Client.hpp"

SearchButton::SearchButton (QWidget *parent) : QPushButton(parent) {
    QObject::connect(this, SIGNAL(clicked(bool)), this, SLOT(search(bool)));
}

void SearchButton::search(bool checked) {
    if (checked) {
        Client::GetInstance().search ();
    }
}

SearchButton* SearchButton::instance = 0;

SearchButton& SearchButton::GetInstance (QWidget *parent){
    if (instance == nullptr) {
        instance = new SearchButton(parent);
    }
    return *instance;
}<commit_msg>Added 8 sec time limit for search<commit_after>//
// Created by vrosca on 1/12/17.
//

#include <future>
#include <Logger.hpp>
#include "SearchButton.hpp"
#include "Client.hpp"

SearchButton::SearchButton (QWidget *parent) : QPushButton(parent) {
    QObject::connect(this, SIGNAL(clicked(bool)), this, SLOT(search(bool)));
}

void SearchButton::search(bool checked) {
    if (checked) {
        setEnabled(false);
        auto future = std::async(std::launch::async, []() {Client::GetInstance().search();});
        auto timeout = future.wait_for (std::chrono::seconds (8));
        if (timeout == std::future_status::timeout) {
            Logger::GetInstance() << "Timeout reached\n";
        }
        setEnabled(true);
    }
}

SearchButton* SearchButton::instance = 0;

SearchButton& SearchButton::GetInstance (QWidget *parent){
    if (instance == nullptr) {
        instance = new SearchButton(parent);
    }
    return *instance;
}
{'fraction_non_alphanumeric': 0.15695067264573992, 'fraction_numerical': 0.008968609865470852, 'mean_word_length': 3.9745222929936306, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5257768', 'n_tokens_mistral': 497, 'n_tokens_neox': 482, 'n_words': 108}