cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
Term::Private::BlockingQueue Class Reference

#include <cpp-terminal/private/blocking_queue.hpp>

Public Member Functions

 ~BlockingQueue ()=default
 
 BlockingQueue ()=default
 
 BlockingQueue (const BlockingQueue &other)=delete
 
 BlockingQueue (BlockingQueue &&other)=delete
 
BlockingQueueoperator= (const BlockingQueue &other)=delete
 
BlockingQueueoperator= (BlockingQueue &&other)=delete
 
Term::Event pop ()
 
void push (const Term::Event &value, const std::size_t &occurrence=1)
 
void push (const Term::Event &&value, const std::size_t &occurrence=1)
 
bool empty ()
 
std::size_t size ()
 
void wait_for_events (std::unique_lock< std::mutex > &lock)
 

Private Attributes

std::mutex m_mutex
 
std::queue< Term::Eventm_queue
 
std::condition_variable m_cv
 

Detailed Description

Definition at line 24 of file blocking_queue.hpp.

Constructor & Destructor Documentation

◆ ~BlockingQueue()

Term::Private::BlockingQueue::~BlockingQueue ( )
default

◆ BlockingQueue() [1/3]

Term::Private::BlockingQueue::BlockingQueue ( )
default

◆ BlockingQueue() [2/3]

Term::Private::BlockingQueue::BlockingQueue ( const BlockingQueue & other)
delete

◆ BlockingQueue() [3/3]

Term::Private::BlockingQueue::BlockingQueue ( BlockingQueue && other)
delete

Member Function Documentation

◆ empty()

bool Term::Private::BlockingQueue::empty ( )

Definition at line 40 of file blocking_queue.cpp.

41{
42 const std::lock_guard<std::mutex> lock(m_mutex);
43 return m_queue.empty();
44}
std::queue< Term::Event > m_queue

◆ operator=() [1/2]

BlockingQueue & Term::Private::BlockingQueue::operator= ( BlockingQueue && other)
delete

◆ operator=() [2/2]

BlockingQueue & Term::Private::BlockingQueue::operator= ( const BlockingQueue & other)
delete

◆ pop()

Term::Event Term::Private::BlockingQueue::pop ( )

Definition at line 12 of file blocking_queue.cpp.

13{
14 const std::lock_guard<std::mutex> lock(m_mutex);
15 Term::Event value = this->m_queue.front();
16 m_queue.pop();
17 return value;
18}

◆ push() [1/2]

void Term::Private::BlockingQueue::push ( const Term::Event && value,
const std::size_t & occurrence = 1 )

Definition at line 30 of file blocking_queue.cpp.

31{
32 for(std::size_t i = 0; i != occurrence; ++i)
33 {
34 const std::lock_guard<std::mutex> lock(m_mutex);
35 m_queue.push(value);
36 m_cv.notify_all();
37 }
38}
std::condition_variable m_cv

◆ push() [2/2]

void Term::Private::BlockingQueue::push ( const Term::Event & value,
const std::size_t & occurrence = 1 )

Definition at line 20 of file blocking_queue.cpp.

21{
22 for(std::size_t i = 0; i != occurrence; ++i)
23 {
24 const std::lock_guard<std::mutex> lock(m_mutex);
25 m_queue.push(value);
26 m_cv.notify_all();
27 }
28}

◆ size()

std::size_t Term::Private::BlockingQueue::size ( )

Definition at line 46 of file blocking_queue.cpp.

47{
48 const std::lock_guard<std::mutex> lock(m_mutex);
49 return m_queue.size();
50}

◆ wait_for_events()

void Term::Private::BlockingQueue::wait_for_events ( std::unique_lock< std::mutex > & lock)

Definition at line 52 of file blocking_queue.cpp.

52{ m_cv.wait(lock); }

Member Data Documentation

◆ m_cv

std::condition_variable Term::Private::BlockingQueue::m_cv
private

Definition at line 43 of file blocking_queue.hpp.

◆ m_mutex

std::mutex Term::Private::BlockingQueue::m_mutex
private

Definition at line 41 of file blocking_queue.hpp.

◆ m_queue

std::queue<Term::Event> Term::Private::BlockingQueue::m_queue
private

Definition at line 42 of file blocking_queue.hpp.


The documentation for this class was generated from the following files: