cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
blocking_queue.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
13
14#include <condition_variable>
15#include <mutex>
16#include <queue>
17
18namespace Term
19{
20
21namespace Private
22{
23
25{
26public:
27 ~BlockingQueue() = default;
28 BlockingQueue() = default;
29 BlockingQueue(const BlockingQueue& other) = delete;
30 BlockingQueue(BlockingQueue&& other) = delete;
31 BlockingQueue& operator=(const BlockingQueue& other) = delete;
34 void push(const Term::Event& value, const std::size_t& occurrence = 1);
35 void push(const Term::Event&& value, const std::size_t& occurrence = 1);
36 bool empty();
37 std::size_t size();
38 void wait_for_events(std::unique_lock<std::mutex>& lock);
39
40private:
41 std::mutex m_mutex;
42 std::queue<Term::Event> m_queue;
43 std::condition_variable m_cv;
44};
45
46} // namespace Private
47} // namespace Term
BlockingQueue & operator=(BlockingQueue &&other)=delete
void push(const Term::Event &value, const std::size_t &occurrence=1)
BlockingQueue(const BlockingQueue &other)=delete
std::condition_variable m_cv
void wait_for_events(std::unique_lock< std::mutex > &lock)
std::queue< Term::Event > m_queue
BlockingQueue & operator=(const BlockingQueue &other)=delete
BlockingQueue(BlockingQueue &&other)=delete
Definition args.cpp:13