OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Channel< T > Class Template Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Channel.hpp>

Inheritance diagram for Slic3r::Channel< T >:
Collaboration diagram for Slic3r::Channel< T >:

Classes

class  Unlocker

Public Types

using UniqueLock = std::unique_lock<std::mutex>
using Queue = std::deque<T>
using LockedConstPtr = std::unique_ptr<const Queue, Unlocker<const Queue>>
using LockedPtr = std::unique_ptr<Queue, Unlocker<Queue>>

Public Member Functions

 Channel ()
 ~Channel ()
void push (const T &item, bool silent=false)
void push (T &&item, bool silent=false)
T pop ()
boost::optional< T > try_pop ()
size_t size_hint () const noexcept
LockedConstPtr lock_read () const
LockedPtr lock_rw ()

Private Attributes

Queue m_queue
std::mutex m_mutex
std::condition_variable m_condition

Detailed Description

template<class T>
class Slic3r::Channel< T >

Member Typedef Documentation

◆ LockedConstPtr

template<class T>
using Slic3r::Channel< T >::LockedConstPtr = std::unique_ptr<const Queue, Unlocker<const Queue>>

◆ LockedPtr

template<class T>
using Slic3r::Channel< T >::LockedPtr = std::unique_ptr<Queue, Unlocker<Queue>>

◆ Queue

template<class T>
using Slic3r::Channel< T >::Queue = std::deque<T>

◆ UniqueLock

template<class T>
using Slic3r::Channel< T >::UniqueLock = std::unique_lock<std::mutex>

Constructor & Destructor Documentation

◆ Channel()

template<class T>
Slic3r::Channel< T >::Channel ( )
inline
41{}

◆ ~Channel()

template<class T>
Slic3r::Channel< T >::~Channel ( )
inline
42{}

Member Function Documentation

◆ lock_read()

template<class T>
LockedConstPtr Slic3r::Channel< T >::lock_read ( ) const
inline
87 {
89 }
Definition Channel.hpp:24
std::mutex m_mutex
Definition Channel.hpp:97
std::unique_lock< std::mutex > UniqueLock
Definition Channel.hpp:21
Queue m_queue
Definition Channel.hpp:96
std::unique_ptr< const Queue, Unlocker< const Queue > > LockedConstPtr
Definition Channel.hpp:38

References m_mutex, and m_queue.

◆ lock_rw()

template<class T>
LockedPtr Slic3r::Channel< T >::lock_rw ( )
inline
92 {
94 }
std::unique_ptr< Queue, Unlocker< Queue > > LockedPtr
Definition Channel.hpp:39

References m_mutex, and m_queue.

◆ pop()

template<class T>
T Slic3r::Channel< T >::pop ( )
inline
63 {
65 m_condition.wait(lock, [this]() { return !m_queue.empty(); });
66 auto item = std::move(m_queue.front());
67 m_queue.pop_front();
68 return item;
69 }
Definition Channel.hpp:19
std::condition_variable m_condition
Definition Channel.hpp:98

References m_condition, m_mutex, and m_queue.

◆ push() [1/2]

template<class T>
void Slic3r::Channel< T >::push ( const T & item,
bool silent = false )
inline
45 {
46 {
48 m_queue.push_back(item);
49 }
50 if (! silent) { m_condition.notify_one(); }
51 }

References m_condition, m_mutex, and m_queue.

◆ push() [2/2]

template<class T>
void Slic3r::Channel< T >::push ( T && item,
bool silent = false )
inline
54 {
55 {
57 m_queue.push_back(std::forward<T>(item));
58 }
59 if (! silent) { m_condition.notify_one(); }
60 }

References m_condition, m_mutex, and m_queue.

◆ size_hint()

template<class T>
size_t Slic3r::Channel< T >::size_hint ( ) const
inlinenoexcept
84{ return m_queue.size(); }

References m_queue.

◆ try_pop()

template<class T>
boost::optional< T > Slic3r::Channel< T >::try_pop ( )
inline
72 {
74 if (m_queue.empty()) {
75 return boost::none;
76 } else {
77 auto item = std::move(m_queue.front());
78 m_queue.pop();
79 return item;
80 }
81 }

References m_mutex, and m_queue.

Member Data Documentation

◆ m_condition

template<class T>
std::condition_variable Slic3r::Channel< T >::m_condition
private

Referenced by pop(), push(), and push().

◆ m_mutex

template<class T>
std::mutex Slic3r::Channel< T >::m_mutex
mutableprivate

Referenced by lock_read(), lock_rw(), pop(), push(), push(), and try_pop().

◆ m_queue

template<class T>
Queue Slic3r::Channel< T >::m_queue
private

The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Channel.hpp