Babel
Epitech's C++ VoIP project
|
Go to the documentation of this file.
8 #include <condition_variable>
32 std::scoped_lock lock(this->
_mutex);
33 return this->
_queue.front();
39 std::scoped_lock lock(this->
_mutex);
40 return this->
_queue.back();
46 std::scoped_lock lock(this->
_mutex);
47 auto t = std::move(this->
_queue.front());
55 std::scoped_lock lock(this->
_mutex);
56 auto t = std::move(this->
_queue.back());
64 std::scoped_lock lock(this->
_mutex);
65 this->
_queue.push_front(t);
72 std::scoped_lock lock(this->
_mutex);
80 std::scoped_lock lock(this->
_mutex);
81 return this->
_queue.empty();
87 std::scoped_lock lock(this->
_mutex);
88 return this->
_queue.size();
94 std::scoped_lock lock(this->
_mutex);
100 template<
typename TimeType>
101 void waitFor(std::chrono::duration<TimeType> time)
103 using namespace std::chrono_literals;
104 std::unique_lock<std::mutex> ul(this->
_waitMutex);
void pushBack(const T &t)
Adds an element to the beginning of the queue.
Definition: TSQueue.hpp:70
void pushFront(const T &t)
Adds an element to the beginning of the queue.
Definition: TSQueue.hpp:62
size_t count()
Returns the number of elements in the queue.
Definition: TSQueue.hpp:85
Definition: IAudioManager.hpp:13
std::deque< T > _queue
Definition: TSQueue.hpp:110
T popBack()
Removes and returns the last element of the queue.
Definition: TSQueue.hpp:53
void clear()
Removes every elements in the queue.
Definition: TSQueue.hpp:92
Thread Safe queue.
Definition: TSQueue.hpp:17
void waitFor(std::chrono::duration< TimeType > time)
Block a thread until the queue is non empty or the timeout is reached.
Definition: TSQueue.hpp:101
bool empty()
Returns true if the queue is empty, false otherwise.
Definition: TSQueue.hpp:78
std::mutex _mutex
Definition: TSQueue.hpp:109
const T & front()
Returns a constant reference to the first element of the queue.
Definition: TSQueue.hpp:30
~TSQueue()
Definition: TSQueue.hpp:24
std::mutex _waitMutex
Definition: TSQueue.hpp:112
std::condition_variable _blocker
Definition: TSQueue.hpp:111
const T & back()
Returns a constant reference to the last element of the queue.
Definition: TSQueue.hpp:37
T popFront()
Removes and returns the first element of the queue.
Definition: TSQueue.hpp:44