<commit_before>#pragma once

#include <thread>
#include <atomic>
#include <vector>
#include <boost/noncopyable.hpp>
#include <fc/log/logger.hpp>

#include "consumer_core.h"
#include "fifo.h"

namespace eosio {

template<typename T>
class consumer final : public boost::noncopyable
{
public:
    consumer(std::unique_ptr<consumer_core<T>> c);
    ~consumer();

    void push(const T& element);

private:
    void run();

    fifo<T> m_fifo;
    std::unique_ptr<consumer_core<T>> m_consumer;
    std::atomic<bool> m_exit;
    std::unique_ptr<std::thread> m_thread;
};

template<typename T>
consumer<T>::consumer(std::unique_ptr<consumer_core<T> > c):
    m_fifo(fifo<T>::behavior::blocking),
    m_consumer(std::move(c)),
    m_exit(false),
    m_thread(std::make_unique<std::thread>([&]{this->run();}))
{

}

template<typename T>
consumer<T>::~consumer()
{
    m_fifo.set_behavior(fifo<T>::behavior::not_blocking);
    m_exit = true;
    m_thread->join();
}

template<typename T>
void consumer<T>::push(const T& element)
{
    m_fifo.push(element);
}

template<typename T>
void consumer<T>::run()
{
    dlog("Consumer thread Start");
    while (!m_exit)
    {
        auto elements = m_fifo.pop_all();
        m_consumer->consume(elements);
    }
    dlog("Consumer thread End");
}

} // namespace
<commit_msg>[sql_db_plugin] name refactoring<commit_after>#pragma once

#include <thread>
#include <atomic>
#include <vector>
#include <boost/noncopyable.hpp>
#include <fc/log/logger.hpp>

#include "consumer_core.h"
#include "fifo.h"

namespace eosio {

template<typename T>
class consumer final : public boost::noncopyable
{
public:
    consumer(std::unique_ptr<consumer_core<T>> core);
    ~consumer();

    void push(const T& element);

private:
    void run();

    fifo<T> m_fifo;
    std::unique_ptr<consumer_core<T>> m_core;
    std::atomic<bool> m_exit;
    std::unique_ptr<std::thread> m_thread;
};

template<typename T>
consumer<T>::consumer(std::unique_ptr<consumer_core<T> > core):
    m_fifo(fifo<T>::behavior::blocking),
    m_core(std::move(c)),
    m_exit(false),
    m_thread(std::make_unique<std::thread>([&]{this->run();}))
{

}

template<typename T>
consumer<T>::~consumer()
{
    m_fifo.set_behavior(fifo<T>::behavior::not_blocking);
    m_exit = true;
    m_thread->join();
}

template<typename T>
void consumer<T>::push(const T& element)
{
    m_fifo.push(element);
}

template<typename T>
void consumer<T>::run()
{
    dlog("Consumer thread Start");
    while (!m_exit)
    {
        auto elements = m_fifo.pop_all();
        m_core->consume(elements);
    }
    dlog("Consumer thread End");
}

} // namespace

{'fraction_non_alphanumeric': 0.169517293804637, 'fraction_numerical': 0.0, 'mean_word_length': 4.684665226781857, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 61, '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': '7226982', 'n_tokens_mistral': 994, 'n_tokens_neox': 957, 'n_words': 168}