<commit_before>#pragma once
// -------------------------------------------------------------------------
//    @FileName      :    NFQueue.h
//    @Author      :    LvSheng.Huang
//    @Date    :    2011-01-21 21:49
//    @Module    :
//
// -------------------------------------------------------------------------

#ifndef _NF_QUEUE_H_
#define _NF_QUEUE_H_

#include <iostream>
#include <map>
#include <list>
#include <algorithm>
#include <thread>
#include <mutex>
#include "NFPlatform.h"

const int QUEUE_SIZE = 10000;

template<typename T>
class NFQueue
{
public:
    NFQueue();
    virtual ~NFQueue();
public:

    bool Push(const T& object);
    bool Pop(T& object);

protected:

    bool Empty();
    //bool Full();

private:
    //  int front;
    //  int rear;
    //  int size;
    std::list<T> mList;
    //Object list[QUEUE_SIZE];
    std::mutex queueMutex;
};

//------------------------------------------------------
template<typename T>
NFQueue<T>::NFQueue()
{
    //  front = rear = 0;
    //  size = QUEUE_SIZE;
    //queueMutex.lock();

}
//------------------------------------------------------
template<typename T>
bool NFQueue<T>::Push(const T& object)
{
    queueMutex.lock();
    if (Full())
    {
        queueMutex.unlock();

        return false;
    }

    mList.push_back(object);
    //  list[rear] = object;
    //  rear = (rear + 1) % size;

    queueMutex.unlock();


    return true;
}
//------------------------------------------------------
template<typename T>
bool NFQueue<T>::Pop(T& object)
{
    queueMutex.lock();
    if (Empty())
    {
        queueMutex.unlock();

        return false;
    }

    object = mList.pop_front();
    //  object = list[front];
    //  front = (front + 1) % size;

    queueMutex.unlock();

    return true;
}
//------------------------------------------------------
template<typename T>
bool NFQueue<T>::Empty()
{
    return mList.empty();
    //  if(rear == front)
    //      return true;
    //  else
    //      return false;
}
//------------------------------------------------------
// template<typename Object>
// bool NFQueue<Object>::Full()
// {
//  if((rear + 1) % size == front)
//      return true;
//  else
//      return false;
// }
//------------------------------------------------------
template<typename T>
NFQueue<T>::~NFQueue()
{
    mList.clear();
}
//------------------------------------------------------


#endif
<commit_msg>queue<commit_after>#pragma once
// -------------------------------------------------------------------------
//    @FileName      :    NFQueue.h
//    @Author      :    LvSheng.Huang
//    @Date    :    2011-01-21 21:49
//    @Module    :
//
// -------------------------------------------------------------------------

#ifndef _NF_QUEUE_H_
#define _NF_QUEUE_H_

#include <iostream>
#include <map>
#include <list>
#include <algorithm>
#include <thread>
#include <mutex>
#include "NFPlatform.h"

const int QUEUE_SIZE = 10000;

template<typename T>
class NFQueue
{
public:
    NFQueue();
    virtual ~NFQueue();
public:

    bool Push(const T& object);
    bool Pop(T& object);

protected:

    bool Empty();

private:
    std::list<T> mList;
    std::mutex queueMutex;
};

//------------------------------------------------------
template<typename T>
NFQueue<T>::NFQueue()
{

}
//------------------------------------------------------
template<typename T>
bool NFQueue<T>::Push(const T& object)
{
    queueMutex.lock();
    if (!Empty())
    {
        queueMutex.unlock();

        return false;
    }

    mList.push_back(object);

    queueMutex.unlock();


    return true;
}
//------------------------------------------------------
template<typename T>
bool NFQueue<T>::Pop(T& object)
{
    queueMutex.lock();
    if (Empty())
    {
        queueMutex.unlock();

        return false;
    }

    object = mList.pop_front();

    queueMutex.unlock();

    return true;
}
//------------------------------------------------------
template<typename T>
bool NFQueue<T>::Empty()
{
    return mList.empty();
}
//------------------------------------------------------
template<typename T>
NFQueue<T>::~NFQueue()
{
    mList.clear();
}
//------------------------------------------------------


#endif

{'fraction_non_alphanumeric': 0.3464655560558307, 'fraction_numerical': 0.008554705087798289, 'mean_word_length': 1.0371389270976616, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '3183007', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1293, 'n_words': 252}