Twitch SDK (Internal)
Public Member Functions | Private Attributes | List of all members
ttv::ConcurrentQueue< TYPE > Class Template Reference

#include <concurrentqueue.h>

Public Member Functions

 ConcurrentQueue ()
 
void clear ()
 
bool empty () const
 
void push (const TYPE &item)
 
void push (TYPE &&item)
 
bool try_pop (TYPE &result)
 
size_t unsafe_size () const
 

Private Attributes

std::queue< TYPE > mQueue
 
std::shared_ptr< IMutexmMutex
 

Detailed Description

template<typename TYPE>
class ttv::ConcurrentQueue< TYPE >

An implementation of a queue which allows concurrent pushes and pops.

Constructor & Destructor Documentation

◆ ConcurrentQueue()

template<typename TYPE>
ttv::ConcurrentQueue< TYPE >::ConcurrentQueue ( )
inline

Member Function Documentation

◆ clear()

template<typename TYPE>
void ttv::ConcurrentQueue< TYPE >::clear ( )
inline

◆ empty()

template<typename TYPE>
bool ttv::ConcurrentQueue< TYPE >::empty ( ) const
inline

◆ push() [1/2]

template<typename TYPE>
void ttv::ConcurrentQueue< TYPE >::push ( const TYPE &  item)
inline

Pushes the item onto the back of the queue in a thread-safe manner.

◆ push() [2/2]

template<typename TYPE>
void ttv::ConcurrentQueue< TYPE >::push ( TYPE &&  item)
inline

Pushes the item onto the back of the queue in a thread-safe manner.

◆ try_pop()

template<typename TYPE>
bool ttv::ConcurrentQueue< TYPE >::try_pop ( TYPE &  result)
inline

Attempts to pop from the front of the queue in a thread-safe manner. If an item is available then the result will be set to the value and true will be returned. Otherwise, false will be returned.

NOTE: Be careful if ITEM doesn't support move assignment since it may call the assignment operator and destructor of the value while under the lock. If this is the case, be sure that the assignment operator and destructor will not in turn call back into the ConcurrentQueue instance or a deadlock may occur.

◆ unsafe_size()

template<typename TYPE>
size_t ttv::ConcurrentQueue< TYPE >::unsafe_size ( ) const
inline

Retrieves the size of the queue. This is not thread safe so use it only to determine the approximate size of the queue.

Member Data Documentation

◆ mMutex

template<typename TYPE>
std::shared_ptr<IMutex> ttv::ConcurrentQueue< TYPE >::mMutex
private

◆ mQueue

template<typename TYPE>
std::queue<TYPE> ttv::ConcurrentQueue< TYPE >::mQueue
private

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