<commit_before>// Copyright (c) 2015 kamyu. All rights reserved.

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <chrono>

using std::cout;
using std::endl;
using std::vector;
using std::queue;
using std::string;
using std::thread;
using std::mutex;
using std::unique_lock;
using std::lock_guard;
using std::condition_variable;
using std::chrono::milliseconds;
using std::this_thread::sleep_for;

template<typename T>
class SyncQueue {
 public:
    void put(const T& val) {
        unique_lock<mutex> lock{mtx_};
        // If the condition is not met,
        // wait until the thread is notified,
        // the mutex is acquirable, and the condition is met.
        cond_.wait(lock, [this]() { return q_.size() != q_size_; });
        q_.emplace(val);
        cond_.notify_all();  // Notify all of the waiting threads.
    }  // Unlock the mutex.

    void get(T *val) {
        unique_lock<mutex> lock{mtx_};
        // If the condition is not met,
        // wait until the thread is notified,
        // the mutex is acquirable, and the condition is met.
        cond_.wait(lock, [this]() { return !q_.empty(); });
        *val = q_.front();
        q_.pop();
        cond_.notify_all();  // Notify all of the waiting threads.
    }  // Unlock the mutex.

 private:
    mutex mtx_;
    condition_variable cond_;
    queue<T> q_;
    const unsigned int q_size_ = 5;
};

class Printer {
 public:
    static void print(const string& s, const int& i) {
        static mutex mtx;
        lock_guard<mutex> lock(mtx);
        cout << s << i << endl;
    }
};

class Producer {<commit_msg>Update producer-consumer.cpp<commit_after>// Copyright (c) 2015 kamyu. All rights reserved.

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <chrono>

using std::cout;
using std::endl;
using std::vector;
using std::queue;
using std::string;
using std::thread;
using std::mutex;
using std::unique_lock;
using std::lock_guard;
using std::condition_variable;
using std::chrono::milliseconds;
using std::this_thread::sleep_for;

template<typename T>
class SyncQueue {
 public:
    void put(const T& val) {
        unique_lock<mutex> lock{mtx_};
        // If the condition is not met,
        // wait until the thread is notified,
        // the mutex is acquirable, and the condition is met.
        cond_.wait(lock, [this]() { return q_.size() != q_size_; });
        q_.emplace(val);
        cond_.notify_all();  // Notify all of the waiting threads.
    }  // Unlock the mutex.

    void get(T *val) {
        unique_lock<mutex> lock{mtx_};
        // If the condition is not met,
        // wait until the thread is notified,
        // the mutex is acquirable, and the condition is met.
        cond_.wait(lock, [this]() { return !q_.empty(); });
        *val = q_.front();
        q_.pop();
        cond_.notify_all();  // Notify all of the waiting threads.
    }  // Unlock the mutex.

 private:
    mutex mtx_;
    condition_variable cond_;
    queue<T> q_;
    const unsigned int q_size_ = 5;
};

class Printer {
 public:
    static void print(const string& s, const int& i) {
        static mutex mtx;
        lock_guard<mutex> lock(mtx);
        cout << s << i << endl;
    }

    Printer() = delete;
    ~Printer() = delete;
    Printer(const Printer&) = delete;
    Printer& operator=(const Printer&) = delete;
};

class Producer {
{'fraction_non_alphanumeric': 0.1306689342403628, 'fraction_numerical': 0.002834467120181406, 'mean_word_length': 2.8526200873362444, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 29, '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': '2198644', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1116, 'n_words': 358}