/* MultithreadingDeque.hpp -- Safe Multithreading Deque class -- */ /* ------------------------------------------------------------------------- */ /* September 20, 2016 -- @Copyright Aymen Soussia. All rights reserved. */ /* (aymen.soussia@gmail.com) */ #pragma once #include #include namespace Mist { namespace Xbee { //***************************************************************************** template class MultithreadingDeque { public: //**************************************************************************** MultithreadingDeque() { } //**************************************************************************** ~MultithreadingDeque() { } //**************************************************************************** void Push_Back(const _T& new_data) { std::lock_guard guard(mutex_); deque_.push_back(new_data); } //**************************************************************************** _T Pop_Front() { std::lock_guard guard(mutex_); _T value = deque_.front(); deque_.pop_front(); return value; } //**************************************************************************** unsigned int Get_Size() { std::lock_guard guard(mutex_); return deque_.size(); } private: std::mutex mutex_; std::deque<_T> deque_; }; } }