<commit_before>/*
 * Copyright (C) 2014 Cloudius Systems, Ltd.
 */

#ifndef QUEUE_HH_
#define QUEUE_HH_

#include <queue>
#include <experimental/optional>

template <typename T>
class queue {
    std::queue<T> _q;
    size_t _max;
    std::experimental::optional<promise<>> _not_empty;
    std::experimental::optional<promise<>> _not_full;
private:
    void notify_not_empty();
    void notify_not_full();
public:
    explicit queue(size_t size);

    // Push an item.
    //
    // Returns false if the queue was full and the item was not pushed.
    bool push(T&& a);

    // pops an item.
    T pop();

    // Consumes items from the queue, passing them to @func, until @func
    // returns false or the queue it empty
    //
    // Returns false if func returned false.
    template <typename Func>
    bool consume(Func&& func);

    // Returns true when the queue is empty.
    bool empty() const;

    // Returns true when the queue is full.
    bool full() const;<commit_msg>queue: switch to circular_buffer<commit_after>/*
 * Copyright (C) 2014 Cloudius Systems, Ltd.
 */

#ifndef QUEUE_HH_
#define QUEUE_HH_

#include "circular_buffer.hh"
#include <queue>
#include <experimental/optional>

template <typename T>
class queue {
    std::queue<T, circular_buffer<T>> _q;
    size_t _max;
    std::experimental::optional<promise<>> _not_empty;
    std::experimental::optional<promise<>> _not_full;
private:
    void notify_not_empty();
    void notify_not_full();
public:
    explicit queue(size_t size);

    // Push an item.
    //
    // Returns false if the queue was full and the item was not pushed.
    bool push(T&& a);

    // pops an item.
    T pop();

    // Consumes items from the queue, passing them to @func, until @func
    // returns false or the queue it empty
    //
    // Returns false if func returned false.
    template <typename Func>
    bool consume(Func&& func);

    // Returns true when the queue is empty.
    bool empty() const;

    // Returns true when the queue is full.
    bool full() const;
{'fraction_non_alphanumeric': 0.11203931203931204, 'fraction_numerical': 0.003931203931203931, 'mean_word_length': 2.9305019305019306, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '6559601', 'n_tokens_mistral': 650, 'n_tokens_neox': 618, 'n_words': 227}